Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Close App API call
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00363604
Message ID:
00363615
Vues:
17
>I have the following API call. It seems to close only certain App's.
>It closes Word documents, but if I try in on the Calculator.Exe, and other test EXE's, it does'nt close them. Is there something wrong here.
>
>
>LPARAMETERS cAppTitle, lAllowSave
>
>#DEFINE WM_DESTROY 0x0002
>#DEFINE WM_CLOSE 0x0010
>
> LOCAL nWinHandle
>
> DECLARE INTEGER FindWindow IN Win32API;
> STRING @lpClassName, STRING @lpWindowName
>
> DECLARE INTEGER SendMessage IN Win32API;
> INTEGER hwnd, INTEGER uMsg,;
> INTEGER wParam, INTEGER lParam
>
> * cAppTitle is the title bar text to search for
> nWinHandle = FindWindow(0, @cAppTitle)
>
> * nWinHandle will be greater than 0 if a match is found.
> IF nWinHandle > 0
>
> =SendMessage(nWinHandle, IIF(lAllowSave, WM_CLOSE,WM_DESTROY), 0, 0)
>
> ENDIF
>
>RETURN nWinHandle > 0

I wouldn't use the in-line IIF() statement, but I don't think that's it. This is a SWAG but some quick testing seems to bear it out. Consider for a moment what's different between the Calculator and Word. The Calculator doesn't do any file I/O and Word does. I tried this with a couple of applications, and it seems to be that if the application does not do file I/O sending WM_DESTROY has no effect. These were all part of the Windows package, BTW. If it does, then it properly destroys the window. In either case, however, WM_CLOSE works. If this is true in all cases, I can't say.

If this is a problem, you might consider testing for the window's presence after issuing WM_DESTROY. If it's still there, then issue WM_CLOSE.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform