Link to home
Start Free TrialLog in
Avatar of wfb
wfb

asked on

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!

Wayne
 
Avatar of inthe
inthe

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.
Avatar of wfb

ASKER

'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!

Wayne
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial