win32 api string commands

May 4, 2010 at 11:27pm
hello everyone,

i am using a string command to get the value of a textbox located in a dialogbox and equate it with variable "X". i am using the folloing:

hwndX = GetDlgItem(hDlg, IDC_FWEDIT);
GetWindowText(hwndX, txt1, 10);
X = atof(txt1);

how can i do the oposite?????
i want to send the value of "X" into the textbox. i've tried setdlgitem() and setwindowtext() but it doesnt work.
PLEASE HELP!!! URGENT!!!!
THANK YOU!
May 5, 2010 at 1:08am
SetDlgItemText(hwnd, ID_BOX, "mytext");

Or you could use SetDlgItemInt() to put a number in there instead so you don't have to convert it to a string.
Last edited on May 5, 2010 at 1:10am
May 5, 2010 at 1:20am
you mean like this?

hwndX = GetDlgItem(hDlg, IDC_FWEDIT);
SetDlgItemInt(hwndXT, IDC_FWEDIT, "123");

i've tried this:

INT_PTR CALLBACK Properties(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hwndXT;

UNREFERENCED_PARAMETER(lParam);
switch (message)
{

case WM_INITDIALOG:
hwndXT = GetDlgItem(hDlg, IDC_FWEDIT);
SetDlgItemInt(hwndXT, IDC_FWEDIT, "123", FALSE);
return (INT_PTR)TRUE;


and still doesnt work.. can you spot anything??
Last edited on May 5, 2010 at 1:30am
May 5, 2010 at 1:38am
ok.. this works:

case WM_INITDIALOG:

SetDlgItemInt(hDlg, IDC_FWEDIT, "2", TRUE);

return (INT_PTR)TRUE;

BUT!! it shows the value of "4231280" no matter what value i tell it to show... hmm.... strange
May 5, 2010 at 1:56am
You don't have to get a window handle to the control when you use SetDlgItemInt() or SetDlgItemText(). The window parameter is the window handle of the window that contains the control.
May 5, 2010 at 2:43am
ok.. now it works.. THANK YOU!!!

but how do I reverse the string?? i want the value of "X" to appear in the textbox..

i've tried several commands but they dont seem to work.

when i wanted the value of "X" to be equal to the textbox value, i used:
int txt1[10];
X = atof(txt1)

what's the oposite of that??
May 5, 2010 at 3:03am
dont worry!! i found it!! its "itoa(value, string, size)" and it works!!

thank you for your help!! you saved me a lot of time!!
Topic archived. No new replies allowed.