Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple Modeless Dialog Boxes...

Posted on 2002-03-06
4
Medium Priority
?
423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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