VB/VB.Net Petite question sur les handles ! :)

Inscrit
9 Octobre 2012
Messages
27
Reactions
0
#1
Bonjour j'ai une petite question ! :)

Lorsque j'effectue la fonction pour récupérer l'handles actif de ma page

SPOILER : CACHER
Dim HandleActif As IntPtr = GetForegroundWindow()
MsgBox(HandleActif)
End Sub


Je récupère donc le handles en chiffre , j'aimerais savoir comment grâce a ce chiffre je pourrais récupérer le nom de la page actif :) !


En attente de votre réponde :)

Merci d'avance :)
 

ToOnS

Membre Actif
Inscrit
8 Avril 2009
Messages
974
Reactions
0
#2
Bonjour ,
Code:
Private Function GetWindowTitle(ByVal window_hwnd As Integer) As String
    Dim length As Integer
    length = GetWindowTextLength(window_hwnd) + 1
    If length <= 1 Then
        ' heu ... y'a pas de titre.
        Return "<" & window_hwnd & ">"
    Else
        Dim buf As String = Space$(length)
        length = GetWindowText(window_hwnd, buf, length)
        Return buf.Substring(0, length)
    End If
End Function
dim Titre_Actif=GetWindowTitle(HandleActif)
MsgBox(Titre_Actif)
 
Inscrit
9 Octobre 2012
Messages
27
Reactions
0
#3
Merci beaucoup :) je test ça ce soir et je te tiens au courant :)
 
Inscrit
9 Octobre 2012
Messages
27
Reactions
0
#4
Et je ne comprend pas le code
windows_hwnd

Ce que ça signifie merci d'avance (et désolé ci ces question peuvent te paraître bête )
 

ToOnS

Membre Actif
Inscrit
8 Avril 2009
Messages
974
Reactions
0
#5
c'est juste une variable , en realite c'est la meme chose que HandleActif (handle est plus souvent appellé hwnd (Handle WiNDow) donc => windows_hwnd , d'ailleur ca devrait meme etre window_hwnd , sans S ou meme juste HWND)
ca aurait pu etre :
Code:
Private Function GetWindowTitle() As String
    Dim HandleActif As IntPtr = GetForegroundWindow()
    Dim length As Integer
    length = GetWindowTextLength(HandleActif) + 1
    If length <= 1 Then
        ' heu ... y'a pas de titre.
        Return "<" & HandleActif & ">"
    Else
        Dim buf As String = Space$(length)
        length = GetWindowText(HandleActif, buf, length)
        Return buf.Substring(0, length)
    End If
End Function
MsgBox(GetWindowTitle)
 
Haut Bas