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
 
wfbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
what about a call to  SetForeGroundWindow(hwnd of app)
0
NickRepinCommented:
I'm agree. 'SetActiveWindow', 'SetFocus' will not help. Call SetForegroundWindow inside the hook on WM_INITDIALOG.
0
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!

Wayne
0
intheCommented:
ok cheers :-)

SetForeGroundWindow()

glad it worked
Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.