Well I set it:
But how do I change it's value?Code:SetDlgItemText(hwnd, IDC_TEXT, "I'm a textbox");
Well I set it:
But how do I change it's value?Code:SetDlgItemText(hwnd, IDC_TEXT, "I'm a textbox");
What do you mean? Change what value?
Code:void function(void) { function(); }
The same way you set it the first time (if I understand your question correctly).
Away.
What I meant was: After setting an edit box, how do I change it's value... Like I start an edit box with the value of "blue" how do I change it to "green"?
Does your solution works for that?
Last edited by lala123; 07-06-2005 at 07:05 PM.
Have you tried that? It works. I promise.Originally Posted by confuted
Away.
Well so why this dosen't work? It compiles and starts but the dialog dosen't show up...
Code:#define WIN32_LEAN_AND_MEAN #include <windows.h> #include "clock.h" SYSTEMTIME time; char strtime[20]; BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: while(1) { GetLocalTime(&time); sprintf(strtime, "%d:%d:%d", time.wHour, time.wMinute, time.wSecond); SetDlgItemText(hwnd, IDC_TIME, strtime); } break; case WM_COMMAND: break; case WM_CLOSE: EndDialog(hwnd, 0); break; default: return FALSE; } return TRUE; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc); }
Last edited by lala123; 07-06-2005 at 08:34 PM.
Since an EDIT box is a window wouldn't the UpdateWindow function work for your purpose? Or does UpdateWindow not affect EDIT windows in the way you want?
Trinity: "Neo... nobody has ever done this before."
Neo: "That's why it's going to work."
c9915ec6c1f3b876ddf38514adbb94f0
UpdateWindow() bypasses the message que and sends the paint msg directly to the callback. Will not change the contents of the edit.
WM_INITDIALOG is called before the DLG is displayed. So putting an infinite loop here will just cause problems (IMO).
I would use a timer message. Create the timer in the init dlg msg with the required tiem interval and it will create a series of WM_TIMER msgs. In the WM_TIMER handler set the edits contents each time the timer msg arrives.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Yes. And that also leaves room for other messages to come in, meaning your window will be able to be updated, closed, etc. correctly.
Code:void function(void) { function(); }
Could you please show me how I would send the WM_TIMER message? And I would handle it just as any other message like the WM_INITDIALOG?
Look at SetTimer() (the timer will fire a msg until killed, not just once)
in wm_initdlg create timer
in wm_close kill timer
in WM_TIMER set you edit each time (the time msg arrives)
SetTimer()
the HWND is that of the DLG
the nIDEvent is a number you use to identify the timer (from other timers you create)
elapse is the interval in millsecs (bast possible is about 15ms)
set lpTimerFunc to NULL so the timer msg comes to your call back
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Thanks a lot for beeing so descriptive and helpfull But it still just flashes and close...
Oh nevermind, I forgot a break; after the WM_TIMER message... It's working nowCode:BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: SetDlgItemText(hwnd, IDC_TIME, FALSE); SetTimer(hwnd, 1, 15, (TIMERPROC) NULL); break; case WM_TIMER: GetLocalTime(&time); sprintf(strtime, "%d:%d:%d", time.wHour, time.wMinute, time.wSecond); SetDlgItemText(hwnd, IDC_TIME, strtime); case WM_CLOSE: KillTimer(hwnd, 1); EndDialog(hwnd, 0); break; default: return FALSE; } return TRUE; }
Last edited by lala123; 07-07-2005 at 09:15 PM.
Ahhh.....see you got it.
Just slip the cheque into the modem......
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill