Click to See Complete Forum and Search --> : Which Control to disply a variable(s)


April 3rd, 1999, 09:57 AM
Wondering which control I would use to disply a variable ( char. or num.) And how is it done.... Please help if you can...
I have tried using a static text box in VC++ 5. and I just get errors..

Masaaki
April 3rd, 1999, 11:25 AM
Hi.

I often use CStaic, CEdit and CListBox to display my data.
I assume that a static text box means CStatic control?
You must change its ID from IDC_STATIC to IDC_MYSTATIC, for example.

When you put label by CStatic control, its id is always IDC_STATIC.
So you must differentiate it.

GetDlgItem(IDC_MYSTATIC)->SetWidnowText("Test");
or
CStatic* ptrCtl = (CStatic*)GetDlgItem(IDC_MYSTATIC);
ptrCtl->SetWindowText("Test");

or make control the member control by class wizard
and m_ctl.SetWindowText("Test");

Hope for help.
-Masaaki Onishi-

April 3rd, 1999, 11:59 AM
ok,
GetDlgItem(IDC_MYSTATIC)->SetWidnowText("Test");
Would '("Test")' be replaced with ("VarriableName") ???? ..
ex... Dialog based program.. click this button and it increasses value X
by value Y... show the new varriable called VarriableName...
??
or am I lost

Masaaki
April 3rd, 1999, 04:59 PM
Hi.
I don't know your approach and code, so can't point out a idea which you want.
Basically, you need some conversion function. For example,
int -> string : itoa() function
or
string -> int: atoi() function and so on.

If you enter the data in Edit box, how this edit box deal with this data as int or string.
This is your choice. But if you deal with the data by plus, you had better use int format.
After this, in order to convert it from int to string in order to use SetWindowText() to CStatic control,
you use conversion function above.

Hope for help.
-Masaaki Onishi-