-
September 14th, 2010, 07:21 AM
#1
Sending IDOK to a dialogbox
I explain my problem.
I wanna make a ticker effect in a edittext field that is in a dialogbox.
Something like this:
o
lo
llo
ello
Hello etc.
Now the problem is that as long as you didnt get out of the case IDOK: you wont see anything.
You only gonna see the (whole) last phrase printed.
Now pure logic tells me that i should call IDOK with sendmessage in a loop.
But if i recall it im never gonna get out of it so its an infinite loop.
Im sure this problem has been solved already i just couldnt find it.
Code:
BOOL CALLBACK DlgProc2 (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
Scrolling(hDlg) ;
return TRUE ;
case IDCANCEL :
EndDialog (hDlg, 0) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
-
September 14th, 2010, 08:01 AM
#2
Re: Sending IDOK to a dialogbox
Since you didn't show the contents of your Scrolling(hDlg) function, I can only guess that you are using SetWindowText in it to first put in the "o", then the "lo", and so on.
If so, immediately after the call to SetWindowText, add a call to the edit control's UpdateWindow() function. This will bypass the normal windows message pump and cause it to update immediately.
Hope that helps.
Be sure to rate those who help!
-------------------------------------------------------------
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
September 14th, 2010, 09:27 AM
#3
Re: Sending IDOK to a dialogbox
Thank you Krmed, that helped!
-
September 14th, 2010, 10:27 AM
#4
Re: Sending IDOK to a dialogbox
I wonder why you were handling the IDOK command for your purposes. You better would have a static text control and output your ticker message using a timer (i. e. handling the WM_TIMER message). That way your dialog wouldn't freeze while outputting the message. You could hold the last state of your ticker in static variables of your handler function.
Code:
...
switch (message)
{
case WM_INITDIALOG :
SetTimer(hDlg, 99, 500, MyTimerProc);
return TRUE;
...
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
static int lastticker = 0;
if (idEvent == 99)
{
HWND hwndTicker = GetDlgItem(hwnd, IDC_STC_TICKER);
switch (lastticker)
{
case 0: SetWindowText(hwndTicker, "o"); break;
case 1: SetWindowText(hwndTicker, "lo"); break;
case 2: SetWindowText(hwndTicker, "llo"); break;
case 3: SetWindowText(hwndTicker, "ello"); break;
case 4: SetWindowText(hwndTicker, "Hello"); break;
}
lastticker = (lastticker+1)%5;
}
}
-
September 15th, 2010, 05:47 AM
#5
Re: Sending IDOK to a dialogbox
Thank you, thats what i was looking for!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|