Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP steals window focus
Message
 
À
09/02/2007 17:43:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
01194295
Message ID:
01194386
Vues:
13
I noticed the same issue some time ago because I have a couple of VFP programs which are called by the Windows Scheduled Tasks applet for some background tasks. My workaround is running these programs by another user account (I created one specifically for this purpose) via the RunAs setting in the Scheduler.

This approach has the following advantages:
1. No focus losing problem
2. Easy debugging (The programs can have a visible UI showing errors as will as the task progress. The UI is hidden from the currently active user, which is not under the account that runs the task. Of course all messageboxes should time out to avoid hanging.)

Ben


>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?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform