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!