I have been working with a Tab control, which uses a modeless dialog for each of the tab pages. While doing this, I was thnking about how you modify the 'standard' message loop to use a GLOBAL variable :
But I got to thinking, why do I need to do this? Don't TranslateMessage and DispatchMessage 'know' the window for which the message is destined (msg.hWnd) is a dialog box?
So... I wrote a little test program to play around. Apparently TranslateMessage and DispatchMessage do not know!
But, near as I can figure out, The only reason to worry about adapting the message loop to handle GLOBAL variables and IsDialogMessage is: Because IsDialogMessage is the ONLY way to get the automatic keyboard interface within a dialog box.
In my tests, the dialogs all responded to mouse clicks on buttons and in editboxes, and in the edit controls the text was fine when retrieved.
Back to my example...
Given that my tab control dialogs need ABSOLUTELY NO KEYBOARD interface (they are views only; three tabs have a listview controls where the user could 'normally' navigate with keys, but I can easily live without a keyboard interface for that), it seems I may eschew the use of the "message loop for programs containing modeless dialogs" and I do not have to worry about keeping track of "which" tab (and therefore "which" modeless dialog) is current.
Do I understand this correctly? Or am I tempting fate, creating some situation which is going to sneak up and some day bite me where I least wish to be bitten?
MCM
PS: I used Jules Marchildon's example code to get started with the tab control. I got it from POFFS, but that means it was here somewhere to start with. Take a look at it someday.
Code:
' "Standard" Message Loop WHILE GetMessage(Msg, %NULL, 0, 0) TranslateMessage Msg DispatchMessage Msg WEND ' "Standard Message Loop adapted for two modeless dialog boxes" WHILE GetMessage(Msg, %NULL, 0, 0) IF (hDlg1 = 0 OR ISFALSE ISDialogMessage (hDlg1, msg)) _ AND (hDlg2 = 0 OR ISFALSE IsDialogMessage (hDlg2, msg)) THEN TranslateMessage Msg DispatchMessage Msg END IF WEND
But I got to thinking, why do I need to do this? Don't TranslateMessage and DispatchMessage 'know' the window for which the message is destined (msg.hWnd) is a dialog box?
So... I wrote a little test program to play around. Apparently TranslateMessage and DispatchMessage do not know!
But, near as I can figure out, The only reason to worry about adapting the message loop to handle GLOBAL variables and IsDialogMessage is: Because IsDialogMessage is the ONLY way to get the automatic keyboard interface within a dialog box.
In my tests, the dialogs all responded to mouse clicks on buttons and in editboxes, and in the edit controls the text was fine when retrieved.
Back to my example...
Given that my tab control dialogs need ABSOLUTELY NO KEYBOARD interface (they are views only; three tabs have a listview controls where the user could 'normally' navigate with keys, but I can easily live without a keyboard interface for that), it seems I may eschew the use of the "message loop for programs containing modeless dialogs" and I do not have to worry about keeping track of "which" tab (and therefore "which" modeless dialog) is current.
Do I understand this correctly? Or am I tempting fate, creating some situation which is going to sneak up and some day bite me where I least wish to be bitten?
MCM
PS: I used Jules Marchildon's example code to get started with the tab control. I got it from POFFS, but that means it was here somewhere to start with. Take a look at it someday.