Solved

Multiple Modeless Dialog Boxes...

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Performance testing with Visual Studio Profession 2015 2 39
dialer.exe 4 68
Which Microsoft MSDN Package Is The One I need? 3 51
Trouble with References... 5 63
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

749 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