Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to ensure a form is shown in an active window?
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00409977
Message ID:
00410959
Views:
21
>Hi Jess,
>
>That's the same logic that I have, but when it runs as a compiled EXE, the main form is relegated to the background.
>

I'd rely on the Win32 API; grab the hWnd of the Form (you can use the FoxTools functions if you include FOXTOOLS.FLL with your app, or use GetActiveWindow() or FindWindow to snag the hWnd using the Win32API) and then explicitly make the Form the topmost Window by calling the Win32API SetWindowPos() to move the Window to the top of the ZOrder:
DECLARE SetWindowPos IN USER32 ;
   INTEGER hWnd, ;
   INTEGER hWndInsertAfter, ;
   INTEGER X, ;
   INTEGER Y, ;
   INTEGER cx, ;
   INTEGER cy, ;
   INTEGER uFlags
#DEFINE HWND_TOP 0
#DEFINE SWP_NOMOVE 2
#DEFINE SWP_NOSIZE 1
#DEFINE SWP_SHOWWINDOW 0x40
=SetWindowPos(hWndForm, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE + SWP_SHOWWINDOW)
BTW, reading the MSDN docs explains in detail why SetForeGroundWindow() doesn't behave as once expected...
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform