Solved

Multiple Modeless Dialog Boxes...

Posted on 2002-03-06
4
405 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
See previously posted comment from me
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now