|
Which part? Getting text from controls? Converting text to integer?
Copying an integer to an integer array? Are you using MFC or straight
Win32 APIs?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i know how i can convert to integer. i use "Convert::Toint32" and i alsoo know how i can copy an integer to an array.
iwould like to know getting text from controls.
i am trying to create windows form application
|
|
|
|
|
Ohhh it's a managed c++ app. You're in the wrong forum to start with.
The TextBox class has a property called Text. If you have a TextBox object
for the edit control, you can get its text with this property:
System::Windows::Forms::TextBox ^MyTextBox = ...;
...
int MyInt = Convert<font color="Red">::</font>ToInt32(MyTextBox->Text); Mark
*edit* fixed wrong operator
Last modified: 11mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What do you mean by "textbox"?
Is it a static control, edit control, listbox control?
|
|
|
|
|
|
|
|
Hi,
I have made a small windows form application with a tableadapter. This is linked with an mdb file. Did this with the new dataset option.
Now I'd like to use the app.config file to make this connectionstring adjustable for placing the mdb file at another location. However program always looks to the connectionstring made with the wizard of the new dataset
Can anyone help me solve this problem? Thanks
|
|
|
|
|
I am trying to cut 3 bytes from the data read from the file and keep getting error. Here is the error and the code.
Error...
**************************************************
///error C2228: left of '.substr' must have
class/struct/union
***************************************************
Code...
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <string>
#include <fstream>
using namespace std;
string DataCut;
struct s {
char test[4];
char test1[4];
};
struct s myStr;
int _tmain(int argc, _TCHAR* argv[])
{
char *str1, Mycut[4];
char str[80000];
string sear1;
size_t result;
fstream file_op("c:\\ProjectRead.txt",ios::in);
while(!file_op.eof())
{
file_op.getline(str, 80000);
str1 = str;
*********************************************************************
Mycut = str.substr(0,4); /// Error here
cout << str1;
*********************************************************************
} file_op.close();
system("PAUSE");
return 0;
}
|
|
|
|
|
I'm going to assume you mean compiler error.
You can't assign a basic_string<CharType, Traits, Allocator> to a char[4] array.
You could copy the basic_string to a char array...
strcpy(Mycut, str.substr(0,4).c_str()); or use an appropriate type
basic_string <char> Mycut = str.substr(0,4);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I use both code and did not help. I even create a struct like this
struct name {
char test[4];
char test1[4];
{
struct name myname;
strcpy(myname.test, str.substr(0,3);
I am still getting the same error.
|
|
|
|
|
msogun wrote: strcpy(myname.test, str.substr(0,3);
I am still getting the same error.
Not surprised, since you are missing a right parenthesis. Even then, your compiler will complain about substr() not belonging to char .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I don't know why, but I assumed your str was a string object
I recommend picking a string type and sticking to it - the mix of char arrays and
string classes just adds unnecessary confusion and complexity.
I'm pretty sure the error messages you are getting will tell you what's wrong.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Also, if you're going to copy 4 characters to your Mycut array, you need to make
its dimension 5 to have room for the null terminator.
char Mycut[5];
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
msogun wrote: char str[80000];
[...]
Mycut = str.substr(0,4); /// Error here
str is defined as a pointer to an array of 8000 chars, allocated on the stack.
Now, you call the member function substr on that pointer.
But pointers do not have member functions to call. Hence the compiler tells you that in order to call a member function, left of it must be a class/struct/union. Not a pointer.
Clearer now?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Adam,
How do you think the code should be. Sample please.
|
|
|
|
|
When I change my application from UNICODE to MultiByte support the look of my UI changes. Understandable, but is there a way to get the XP (VS 2005) look and feel while still supporting MultiByte character set?
Thanks.
|
|
|
|
|
masnu wrote: is there a way to get the XP (VS 2005) look and feel while still supporting MultiByte character set?
Try adding the following line to the bottom of your stdafx.h file...
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
...and rebuild.
masnu wrote: When I change my application from UNICODE to MultiByte support the look of my UI changes. Understandable
How is that understandable? Why would the character set used by the code have an effect on the UI?
Internally, Windows APIs use all Unicode - has been that way for a long time.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Look at the bottom of your stdafx.h file... you'll find a group of #pragma statements surrounded by
#ifdef _UNICODE
...
...
...
#endif
Remove the line with the #ifdef _UNICODE and the corresponding #endif.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I have a rookie question for you guys. I need to write a GUI based application (not too complex) for a windows platform that cannot have the .NET framework installed. The .NET Framework is absolutely out of the question.
I've attempted to create a Windows Form application for C++ under Visual Studio 05, but when I compile it runs on my machine but not the remote machine. All it is is a blank form, so it's not a code bug.
How should I go about creating a Form based GUI app for my circumstances?
Thanks...
|
|
|
|
|
MFC?
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
(now my ignorance will become evident)
I've just created an MFC solution in VS05, but wasn't sure what to choose for the project settings so I used the defaults. I'm not seeing how to interact with the main form. Can I use the graphical form designer with this type of project?
|
|
|
|
|
yes
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
Could you elaborate on how to do so? When I try to add a form, it wants to add support for CLR, which means .NET framework, if I'm not mistaken..
|
|
|
|
|
Ah! It's called a dialog here. I've added a Dialog and can design willy nilly. Sweet.
|
|
|
|