Solved

Multiple Modeless Dialog Boxes...

Posted on 2002-03-06
4
417 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

728 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