• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

Why is File Selector being hidden?

I have a console mode Fortran main program that runs from the command line. This program calls a 'C' routine which, in turn, calls 'GetOpenFileName' to bring up a file selector. This seems to work fine, EXCEPT if one or more other windows are on the screen. In that case, when 'GetOpenFileName' is called, the console window and the file selector (whose parent is usually the console window - see below) are partially or fully hidden behind the other windows! Obviously, such behavior will confuse the user!

I have tried passing 'GetOpenFileName' the handle of the console window (obtained via a call to 'FindWindow') AND a NULL handle. The behavior is the same in both cases, EXCEPT the file selector is either inside the DOS window, or in the upper left corner of the desktop. In either case, both the file selector and the the console window are being obscured.

I notice this odd behavior only if the Fortran main program does a READ from the console window before calling the routine that brings up the file selector; just writing to the console window does not seem to cause this problem. I'm not sure what this means...

In an attempt to fix this problem, I attached a HOOK routine to 'GetOpenFileName'. Inside the HOOK routine, I intercept the WM_INITDIALOG message and, when it is received, try calling routines such as 'SetActiveWindow', 'SetFocus', etc. in an attempt to make the file selector & the console window visible. For each test, I passed these routines either the handle of the file selector (as passed to the HOOK function), or the parent of the file selector (obtained via 'GetParent').

None of my attempts has worked - the file selector & console window still want to "hide"!

Any suggestions would be greatly appreciated!

  • 2
1 Solution
what about a call to  SetForeGroundWindow(hwnd of app)
I'm agree. 'SetActiveWindow', 'SetFocus' will not help. Call SetForegroundWindow inside the hook on WM_INITDIALOG.
wfbAuthor Commented:
'SetForeGroundWindow' works! Many thanks to both of you. Since 'inthe' provided the answer first, it would seem that he should be awarded the 200 points. (If there were some way to 'split' the points, I'd award 150 points to 'inthe' and 50 points to 'NickRepin'.)

'inthe': if you submit your response as an "answer", I'll award the points...

Again, thanks very much to all!

ok cheers :-)


glad it worked
Regards Barry

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now