Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1 View

Dialog box is hidden

When my application opens a dialog box, it is usually hidden by other windows--both that of my own app and other apps that just happen to be open and occupy an unfortunate area of my screen. Is there any way to force my dialog to be on top? This is wreaking havoc with my customers who don't know that the dialog is there because they can't see it.

0 Kudos
7 Replies
Highlighted
Black Belt
1 View

In the other thread about

In the other thread about starting an editor, you mentioned that you were throwing dialog boxes up from a console application.  Is this the same application?

Assuming that you are not deliberately creating the dialog in the background (not likely), what I suspect is happening is that the console application is not considered the "foreground window" process at the time that it throws up the dialog box (it can't be the foreground window process - as it has no windows - the process that will be considered having the foreground window will be the process that provides the console support).  The windowing system restricts processes that are not the foreground window from grabbing the focus without the user's involvement.

To confirm my suspicions, perhaps experiment with, and read the documentation, on the SetForegroundWindow API.  If my suspicions are right, then you will at least get a flashing title bar for your dialog box.

This is a complication that arises from having a console program throw up windows.

 

0 Kudos
Highlighted
1 View

You could use the result of a

You could use the result of a GetForegroundWindow() call as the hWnd argument when putting up the dialog box. This works well in console applications. If you use NULL, then the desktop is considered the parent window.

Retired 12/31/2016
0 Kudos
Highlighted
New Contributor I
1 View

I use just this IVF Fortran

I use just this IVF Fortran call to activate the dialogs:

lret = DLGMODAL (dlg)

i.e. the optional 2nd argument, hwndParent, is missing. According to the IVF documentation, then "the Windows desktop window is the parent window." I suppose this is what Steve means by "If you use NULL, then the desktop is considered the parent window."

I don't understand how the "parent window" affects the focus, or stack order, of the subject window. Is it logical that parent = desktop has a different effect from parent = MyConsoleApp?

I will experiment with Ian's and Steve's suggestion and report back. 

0 Kudos
Highlighted
1 View

Yes, you need to pass the

Yes, you need to pass the second argument. The default is that the desktop background is the parent, so the dialog appears above that. If your console window has focus, then it could obscure the dialog.  Here's what the documentation says:

 If omitted, the value is determined in this order: 

  1. If DLGMODAL is called from the callback of a modal or modeless dialog box, then that dialog box is the parent window.

  2. If it is a QuickWin or Standard Graphics application, then the frame window is the parent window.

  3. The Windows* desktop window is the parent window.

Retired 12/31/2016
0 Kudos
Highlighted
New Contributor I
1 View

OK, progress. By opening the

OK, progress. By opening the dialog window using

lret = DLGMODAL ( dlg, GetForegroundWindow() )

The window will be on top of my program window. And, I can locate the dialog w.r.t. the upper left corner of my program window. Now, if only I could control the location of the program window w.r.t. the desktop. Is there a way to do that? (I kow how to locate the project frame when using a Quickwin project, but this is a console project.)

Further, the dialog my still be hidden by other app windows. In this case, my program launches a pdf viewer using ShellExecute, and that appears on top of everything else on the desktop. Then, my program launches a dialog, and that shows up on top of my program (thanks for the solution Steve!) but it is still under the pdf viewer. So, is there a way to control the location of a window launched by ShellExecute? Perhaps by tweaking the lpParameters structure (which is currently null)?

0 Kudos
Highlighted
1 View

No, you have no control over

No, you have no control over window position of the spawned program.

Retired 12/31/2016
0 Kudos
Highlighted
Beginner
1 View

I think this is a bit similar

I think this is a bit similar to a problem I have with a MDI application as the message box sometimes poop up, other times not. Please see code fragment below.

So I the tried the GetForegroundWindow()  (I used to have NULL),. However, the problem was not solved in my case..

 

 

  1. case (WM_CLOSE)
  2. ! Free the INFO data that associates with this
  3. ! window also, reset the menu.
  4. iret = messagebox(GetForegroundWindow(),'OK to close the file?'//""C, &
  5. 'TVA'//""C, MB_ICONQUESTION.OR. &
  6. MB_OKCANCEL)
  7. if(iret == IDCANCEL) then
  8. MDIWndProc = 0
  9. return
  10. else
0 Kudos