Handle d'un prog?

Résolu
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 - 16 sept. 2004 à 18:15
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 17 sept. 2004 à 20:01
bonjour.
comment fait on pour recupere le handle des form des prog en cour et le handle des objet qu'elle contient (je precise que le prog en question n'est peut etre pas ecrit en vb)
merci
voila
VirusMan :-p

16 réponses

cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 9
16 sept. 2004 à 18:41
GetWindow
FindWindow(Ex)
EnumWindows
EnumchildWindows

etc...

tu peux soit obtenir directement le handle de la fenetre en utilisant son nom ou sa classe soit en recuperant d'abord le ProcessId puis la liste des fenetres. Enfin les techniques sont nombreuse et offre des avantages et des inconvenients cela depend des besoins

@+

E.B.
3
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
16 sept. 2004 à 19:45
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Call SetWindowText(Text1.hwnd, "ce texte")
3
cs_EBArtSoft Messages postés 4525 Date d'inscription dimanche 29 septembre 2002 Statut Modérateur Dernière intervention 22 avril 2019 9
16 sept. 2004 à 19:53
SetWindowText ou SendMessage + WM_SETTEXT

@+

E.B.
3
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
16 sept. 2004 à 19:55
ça marche pareil.

Const WM_SETTEXT = &HC

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Call SendMessage(Text1.hwnd, ,WM_SETTEXT, -1, ByVal "ce texte")
3

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
16 sept. 2004 à 20:09
il y a une virgule en trop pardon

Call SendMessage(Text1.hwnd, WM_SETTEXT, -1, ByVal "ce texte")

sinon j'ai essayé SetWindowText sur un autre processus, chez moi ça marche.
3
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
16 sept. 2004 à 21:09
je mets l'exemple de allapi, mais faudra l'adapter

'in a form
Private Sub Form_Load()
Me.AutoRedraw = True
EnumChildWindows GetDesktopWindow , AddressOf EnumChildProc, ByVal 0&
End Sub

'in a module
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long

Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave <> "" Then Form1.Print sSave
'continue enumeration
EnumChildProc = 1
End Function
3
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
16 sept. 2004 à 19:18
merci EB mais comment on fait pour changer le texte d'un textbox se trouvant sur une form dont on connait le handle?
VirusMan :-p
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
16 sept. 2004 à 19:42
SendMessage avec WM_SETTEXT

ciao...
BruNews, MVP VC++
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
16 sept. 2004 à 19:56
SetWindowText n'est valide que dans son propre processus.

ciao...
BruNews, MVP VC++
0
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
16 sept. 2004 à 20:15
merci je demandé pas tan!
une derniere des derniere question:
comment recup le handle des textbox et composant d'une form (le code detaillé serrai le bienvenu)
si kelqu'un repond a ca je n'aurai plus de question
un grand merci
VirusMan :-p
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
16 sept. 2004 à 20:55
EnumchildWindows comme te l'a deja dit EB.
Code detaille....

ciao...
BruNews, MVP VC++
0
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
17 sept. 2004 à 07:27
merci!
vraiment vous etes super les gars merci
vous aurez surement droit a ma source vers le semaine prochaine (c'est un cracker de cle cd)
merci beaucoup!
VirusMan :-p
0
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
17 sept. 2004 à 07:45
Aie!
y a un prob!
comment on fait pour modifier le texte dont on connait le nom (ou le contenu)?
VirusMan :-p
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
17 sept. 2004 à 18:37
Je comprends pas trop la question
si tu as le texte tu peux trouver le handle, et avec le handle tu peux modifier le texte.
pour le nom, si ça peut t'aider tu peux aller la classe en fournissant le Handle. par exemple
un CommandButton --> ThunderCommandButton
un TextBox --> Thunder Textbox
un Label n'a pas de Handle

Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Dim tText As String
Dim Length As Long
tText = Space$(255)
Length = GetClassName(tHandle, tText, 255)
tText = Left$(tText, Length)
0
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
17 sept. 2004 à 19:43
enfait tu voit le truc de gobillot et bien ca me list le nom des fentres ouvertes d'accord,mais comment faire pour recupere le handle qui va avec le nom?
VirusMan :-p
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
17 sept. 2004 à 20:01
quel nom donne un exemple.

après GetWindowText

If sSave = "Lenomquetucherche" then
msgbox "j'ai trouvé le handle: " & hwnd
end if
0
Rejoignez-nous