Solved

Multiple Modeless Dialog Boxes...

Posted on 2002-03-06
4
409 Views
Last Modified: 2013-12-03
This is a fairly easy question.  With one modeless dialog box, my loop in winmain looks like:

while (GetMessage (&msg, NULL, 0, 0))
     {
          if (hDlgModeless == 0 || !IsDialogMessage(hDlgModeless, &msg))
          {              
               TranslateMessage(&msg);
               DispatchMessage(&msg);
          }
               
     }

If I were to have 2 modeless dialog boxes in my program (say, hDlgModelessA and hDlgModelessB)

Could I do something like:

while (GetMessage (&msg, NULL, 0, 0))
     {
          if ( (hDlgModelessA == 0 || !IsDialogMessage(hDlgModelessA, &msg)) && (hDlgModelessB == 0 || !IsDialogMessage(hDlgModelessB, &msg) )
          {              
               TranslateMessage(&msg);
               DispatchMessage(&msg);
          }
               
     }

Or is the process different when dealing with multiple modeless dialog boxes?
0
Comment
Question by:navigator010897
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:JefDuncan
ID: 6845641
navigator,
The process is no different. However, you may want to try something like:

HWND hModelessDlgs = {hDlgModelessA, hDlgModelessB};

#define dim(X) sizeof((X)) / sizeof((X)[0])

while (GetMessage(&msg, NULL, 0, 0))
{
    bool processMsg = true;
    for (int i = 0; processMsg && i < dim(hModelessDlgs); i++)
    {
        if (hModelessDlgs[i] == NULL || !IsDialogMessage(hModelessDlgs[i], &msg))
            processMsg = false;
    }
    if (processMsg)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}

HTH,
JefDuncan
0
 
LVL 1

Accepted Solution

by:
JefDuncan earned 50 total points
ID: 6845648
navigator,

I need to make one small change:

if (hModelessDlgs[i] == NULL || !IsDialogMessage...

SHOULD BE:

if (hModelessDlgs[i] && IsDialogMessage(hModelessDlgs[i], &msg))
0
 
LVL 1

Author Comment

by:navigator010897
ID: 6845734
I never would have thought of a solution like that.  It definitly makes it easier to deal with it, especially if you have many modeless dialog boxes...
0
 
LVL 1

Author Comment

by:navigator010897
ID: 6845738
See previously posted comment from me
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question