win32 api string commands

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!
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
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
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
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.
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??
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.