Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP steals window focus
Message
From
09/02/2007 17:43:25
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
VFP steals window focus
Miscellaneous
Thread ID:
01194295
Message ID:
01194295
Views:
58
I'm having a problem with VFP 9 exe stealing the focus from the active window when they don't have a app window.

To reproduce this behavior:

Create a new project. Add a .prg, with nothing in it (it doesn't matter if it does something or not, it's just simpler if it does nothing). Add a text file, named "config.fpw", with the following:

---
SCREEN = OFF
RESOURCE = OFF
---

Compile to an .exe. Now open Task Manager, and make sure it is set to be "Always on Top". Open up a session of cmd.exe, and run your exe from there.

It will "steal" the focus from whatever window is active (apparently to the VFP window... which isn't visible), and then close, returning focus to the topmost window. These particular instructions are just to give an obvious visual demonstration of the effect, but this happens no matter how you run the EXE, even if you use CreateProcess() and specify SW_HIDE.

This is Very Bad for my intended application.

Usually it's not too much of a problem, because the focus quickly goes back to the current app, and all you see is a flicker effect, and while I could work around this by creating a VFP OLE instance or something like that, I'd rather fix whatever is causing this problem than resort to hacks.

This could be a Windows problem, I suppose, but I don't see any other programs causing the same behavior, and isn't Windows XP supposed to prevent applications from stealing the focus? Anyone have an idea?
Next
Reply
Map
View

Click here to load this message in the networking platform