Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I close an another program?
Message
De
14/07/2000 08:43:04
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
How can I close an another program?
Divers
Thread ID:
00392323
Message ID:
00392323
Vues:
56
Hi All,

Suppose I run Notepad and it gives the window title as "Untitled - Notepad". If I call the below program
CloseProgram("Untitled - Notepad")
it does not close the notepad. Could anyone please explain the reason?

********
FUNCTION CloseProgram
LPARAMETERS cWindowName
Local hMainWnd, hWnd, cWindowTitle
#define GW_CHILD 5
#define GW_HWNDNEXT 2
#define CRLF Chr(13)+Chr(10)

DECLARE INTEGER GetDesktopWindow IN WIN32API
DECLARE INTEGER GetWindow IN WIN32API INTEGER, INTEGER
DECLARE INTEGER GetWindowText IN WIN32API INTEGER, STRING, INTEGER
DECLARE INTEGER IsWindowVisible IN WIN32API INTEGER
DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER
DECLARE INTEGER DestroyWindow IN WIN32API INTEGER

hMainWnd = GetDesktopWindow()
hWnd = GetWindow(hMainWnd, GW_CHILD)
Do While hWnd > 0
   If IsWindowVisible(hWnd) <> 0
      cWindowTitle = Space(100)
      GetWindowText(hWnd, @cWindowTitle, 100)
      cWindowTitle = Trim(cWindowTitle)
      cWindowTitle = Left(cWindowTitle, Len(cWindowTitle)-1)
      If Upper(cWindowName) $ Upper(cWindowTitle)
         =DestroyWindow(hwndNext)
         Exit
      EndIf
    EndIf
    hWnd = GetWindow(hWnd, GW_HWNDNEXT)
EndDo
ENDFUNC
***************

I even tried below

=SetForegroundWindow(hwndNext)
Keyboard '{ALT+F4}'
*****************
This one closes my program only :-) What am I missing here? Thanks for your valuable time and response.

Regards
Vijay
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform