Probleme SEND MESSAGE , URGENT

felix_12 Messages postés 11 Date d'inscription samedi 31 juillet 2004 Statut Membre Dernière intervention 13 juillet 2007 - 15 déc. 2005 à 06:52
felix_12 Messages postés 11 Date d'inscription samedi 31 juillet 2004 Statut Membre Dernière intervention 13 juillet 2007 - 30 déc. 2005 à 07:11
Voila j'ai une form avec un bouton 1 timer et 1 listebox suivant mon code je voudrait que lorsque l'on presse ctrl 1 sur une fenetre windows , elle se rajoute dans la listebox sous forme "NOM --- Hwnd" Et que lorsque l'on fait ctrl et shift simultanéement cela cache toute les fenetre dans la liste , ceci marche sur mon code! mais je peux cacher et montrer ensuite une fenetre qu'une seule fois ... je ne comprend pas pourquoi c'est pour cela que je demande votre aide !
Voici Mon code
:

<HR>

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal uAction As Long) 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
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Hided As Boolean


Private Sub Command1_Click()
List1.RemoveItem (List1.ListIndex)
End Sub


Private Sub Command2_Click()
Unload Me
End Sub


Private Sub Form_Load()
Hided = False
End Sub


Private Sub Timer1_Timer() 'detecte la pression de touche
Dim Retour As Long
touche1 = GetAsyncKeyState(49)
ctrl = GetAsyncKeyState(17)
If (touche1 And ctrl) <> 0 Then 'ajouter un élément dans la liste
Dim hWndlength As Long, hWndTitle As String
Dim hwnd As Long
hwnd = GetForegroundWindow
hWndlength = GetWindowTextLength(hwnd)
hWndTitle = String$(hWndlength, 0)
GetWindowText hwnd, hWndTitle, (hWndlength + 1)
List1.AddItem hWndTitle & "---" & hwnd
If List1.List(List1.ListCount - 1) = List1.List(List1.ListCount - 2) Then 'supression d'un élément si element precedent est le meme
List1.RemoveItem List1.ListCount - 1
End If

End If
shift = GetAsyncKeyState(16)
If (shift And ctrl) <> 0 Then
'CACHER /MONTRER les fenetre dans la liste
Call cachetout
End If


End Sub


Function cachetout()
Dim E As Long, Handlecache() As String
E = 0 'Remise a zero de la variable E
While E < List1.ListCount 'Boucle pour chaque élément dans la liste
Handlecache() = Split(List1.List(E), "---", -1) 'Récupération du hwnd
If Hided = False Then
Call ShowWindow(Handlecache(1), SW_HIDE) 'cacher la fenetre
End If
If Hided = True Then
Call ShowWindow(Handlecache(1), SW_SHOW) 'montrer la fenetre
End If
E = E + 1 'incrémentation de la variable E
WendIf Hided True Then Hided False 'Changer l'état de la variable "HIDED"If Hided False Then Hided True 'Changer l'état de la variable "HIDED"
End Function



<HR>

Merci D'avance , Repondez moi vite!
XhK_UnLiMiT

2 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
15 déc. 2005 à 10:06
faut faire varier ton indice.

et tu connais pas le Else ?







If Hided = False Then
Call ShowWindow(Handlecache(1), SW_HIDE) 'cacher la fenetre
End If
If Hided = True Then
Call ShowWindow(Handlecache(1), SW_SHOW) 'montrer la fenetre
End If

Daniel
0
felix_12 Messages postés 11 Date d'inscription samedi 31 juillet 2004 Statut Membre Dernière intervention 13 juillet 2007
30 déc. 2005 à 07:11
si tu regarde correctement le code s'execute une fois , mais c'est sa le problème il n'e cache et fait apparaître tous les programmes dans la liste qu'une fois et je devrait pouvoir recommencer , non?
une aide serait de grand besoin
merci d'avance!!!



XhK_UnLiMiT
0
Rejoignez-nous