DoModal - window not at front? (Alt fixes it!)

Hi Experts,

I'm popping up the simplest little window with DoModal - I don't see it, but if I simply press the "Alt" button, and just the Alt button, my window comes to the top of the z-order.  I'm using Visual C++ 9.0 with Vista.  What gives??
LVL 1
threadyAsked:
Who is Participating?
 
threadyConnect With a Mentor Author Commented:
I found the problem - it has to do with any window- basically, my OpenGL window processes the WM_PAINT message.  In my OnPaint function, I call my virtual function DrawGLScene and return.  The fix was to call the __super::OnPaint....  My dialog boxes simply were not being painted because I handled the WM_PAINT without passing it on...

0
 
DanRollinsCommented:
You may need to show your code...
But my first guess is that you have set the parent of the dialog to be the desktop rather than your main wiindow.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
>>> I'm popping up the simplest little window with DoModal

from where?  A thread, a dll ?

(Sounds like a bug you have there)
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
threadyAuthor Commented:
It's from a simple dialog based app - no threads except the main thread.  I agree - does sound like a hidden bug somewhere......  just grasping at straws because of the weird fact that it works - just that Alt brings the window to front!

Mike
0
 
threadyAuthor Commented:
However, there are 3 OpenGL windows in this app (right on the main frame of the dialog based app - the same window I'm popping up the new CDialog).......  not so simple I guess...
0
 
DanRollinsCommented:
Show the code that you use to to open/display the dialog.  In what object does that code reside?
0
 
threadyAuthor Commented:
Hi Dan,

It's just a really simple CDialog derived class.  I do the following:

CMyDialog dlg;
dlg.DoModal();

I'm sure it has more to do with the OpenGL windows that are just behind it.  They are constantly grabbing the drawing context (because they are all "competing" for OpenGL draw commands)...  Somehow the z order of even a modal window is being affected....  (CMyDialog has to edit controls in it - it's really a teeny tiny window that has nothing to do with the problem).....

I'd provide more code, but I'd have to include the whole project..  It's too big...

Thanks,
Mike
0
 
DanRollinsCommented:
The code you showed did not indicate what object that code was in.  That can be important because the parent window is based on the parent object when the default constructor is used.  
Yes, it is probably related in some way to the OpenGL windows.  But parent/child relationships are very often at the root of these things.
Another possibility:  In OnInitDialog(), do you set the focus?  If so, that fn should return FALSE.
0
 
threadyAuthor Commented:
The CDialog is instantiated in the main CDialog of the application.  The main CDialog contains 3 OpenGL custom controls - there is also a button that calls my the code that invokes the DoModal...

Although I am not calling SetFocus in OnInitDialog, I tried returning FALSE instead, no luck.

Another interesting point - when I click the button that invokes the DoModal, the window is of course present, but invisible.  Pressing Alt at this point brings it to the front.  However, if instead of Alt, I press escape, it does also have focus, control comes back to the dialog that it was invoked from (i.e., escape closes the dialog and exits the DoModal state)....

I know it's not easy to try to help me with this - it's all shots in the dark for you, I appreciate your help.  I was sure your last comment would be the solution....  (until I tried it)...

Mike
0
 
DanRollinsCommented:
Diagnostic thought:  Arrange the OpenGL windows so that there i a gap at the point where the small modal dialog will appear.  Does a part of the popup dialog box appear in the gap (without needing to press Alt)?
Diagnotic:
Run Spy++ and monitor all messages sent to both the main dialog and the popup.  See what sequence occurs when you press Alt.  Might yeild a clue
There should be a normal/simple way to do this... Obviously, DoModal() normally displays the dialog immediately.  But there are a number of things you can try to force the display.  For instance, call Invalidate() on the parent window (main dialog) right before returning from OnInitDialog of the popup.  Or maybe a SetWindoePos or MoveWindow on the popup will shake things up.
 
0
 
threadyAuthor Commented:
Hi Dan,

I tried moving the window below so that it wasn't above an OpenGL window.  I also tried Invalidate at the end of the new window's initdialog - and SetWindowPos - no luck.  I didn't see anything special wih Spy++ either....  :-(      all good ideas, but just not lucky.

Thanks,
Mike
0
 
DanRollinsCommented:
Check the parenting of OpenGL windows.  Are these ActiveX controls?  Are they defined as child windows of the main dialog?
0
 
threadyAuthor Commented:
The parent of COpenGL windows are CWnd.   I used CStatic controls to position them on my main CDialog window....
0
 
DanRollinsCommented:
There might be an assumed parameter that sets the parent to the wrong window.  
Please show the code you use to create one of the OpenGL windows.  
0
 
masheyCommented:
I have a question on this. I have a main_UI dialog box, whose InitDialog() spawns a thread which calls an other dialog box (login dialog box). The login dialog box calls the DoModal(), however, both the Main_UI and the login dialog box act as two separate windows.
My question is 1. How to establish a parent-child relationship between the Main_UI and the login dialog box.

2. How to make the login dialogbox truly Modal?

I am using Visual Studio 9.0.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.