cs_psychodingue
Messages postés67Date d'inscriptionsamedi 5 janvier 2002StatutMembreDernière intervention 2 juin 2005
-
8 avril 2002 à 18:25
cs_psychodingue
Messages postés67Date d'inscriptionsamedi 5 janvier 2002StatutMembreDernière intervention 2 juin 2005
-
8 avril 2002 à 23:53
Comment je peux faire pour trouver le hwnd de la fenêtre active svp? En fait, je voudrai pouvoir détecter si la fenêtre de mon prog est celle active ou pas, pour ça, je pensais comparer le hwnd de la fenêtre active et celui de la fenêtre de mon prog.
Merci
@ bientôt et bonne semaine
cs_Jack
Messages postés14006Date d'inscriptionsamedi 29 décembre 2001StatutModérateurDernière intervention28 août 201579 8 avril 2002 à 20:17
Voilà ce qu'il faut faire :
' Recherche le nom de l'appli active
hActive = GetForegroundWindow()
' Rechercher le nom du bandeau de l'appli
Length = GetWindowTextLength(hActive)
NomTache = Space$(Length + 1)
Length = GetWindowText(hActive, NomTache, Length + 1)
NomTache = Left$(NomTache, Len(NomTache) - 1)
C'est tout.
Bien sur, il faut déclarer les fonctions associées dans la partie Déclaration de ta forme :
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
----------------------------------
C'est tout
Jack
cs_psychodingue
Messages postés67Date d'inscriptionsamedi 5 janvier 2002StatutMembreDernière intervention 2 juin 2005 8 avril 2002 à 23:53
merci beaucoup, mais c'est bon, j'ai trouvé, et c beaucoup + simple:
j'ai pris la fonction getactivewindow et je l'ai comparé à me.hwnd et c tout
merci