Rennomer la bonne fenêtre

Contenu du snippet

Waaala comment renommer la fenêtre que l'on veut ( tout du moins sous win9x, la gestion des process étant différente sous windows NT ). Ne faite pas de virus, faites l'amour et pas la guerre!

Nécessite une form, une listbox, un label, une textbox et deux boutons. Mettez tout en vrac, la déco est toto-matic.

Source / Exemple :


Private Declare Function RecupLaFenetre Lib "user32" Alias "GetWindow" _
                        (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function RecupLePidDuPapa Lib "user32" Alias "GetParent" _
                                              (ByVal hwnd As Long) As Long
Private Declare Function RecupLaLongueurDeLeTexte Lib "user32" Alias _
                   "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function RecupLeTexte Lib "user32" Alias "GetWindowTextA" _
  (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function ModifLeTexte Lib "user32" Alias "SetWindowTextA" _
                     (ByVal hwnd As Long, ByVal lpString As String) As Long

Dim IWanaKeepItSomewhere$(200)

Private Sub Command1_Click()
 If List1.ListIndex <> -1 Then
  LeHandle = IWanaKeepItSomewhere$(List1.ListIndex + 1)
  Call ModifLeTexte(LeHandle, Text1.text)
  List1.Clear
  Call LoadTaskList
 End If
End Sub

Private Sub Command2_Click()
 End
End Sub

Private Sub Form_Load()
 Call InitBg
 Call LoadTaskList
End Sub

Sub InitBg()
 List1.Top = 80: List1.Left = 0: List1.Appearance = 0
 List1.Width = 2000: List1.Height = 1400: List1.BackColor = &H80000018
 Text1.Top = 300: Text1.Left = 2100: Text1.Appearance = 0
 Text1.Width = 2000: Text1.Height = 300: Text1.BackColor = &H80000018
 Text1.text = "": Label1.Caption = "Entrez le Nouveau nom :"
 Label1.FontName = "Arial": Label1.FontUnderline = True
 Label1.Top = 0: Label1.Left = 2100
 Command1.Caption = "&Modifier": Command2.Caption = "&Quitter"
 Command1.Width = 2000: Command1.Height = 300
 Command1.Default = True: Command2.Cancel = True
 Command1.Top = 700: Command1.Left = 2100
 Command2.Width = 2000: Command2.Height = 300
 Command2.Top = 1100: Command2.Left = 2100
 Me.Width = 4300: Me.Height = 1900
 Me.Caption = "Mémère Process [Re]-Name"
 Me.Top = Int((Screen.Height - Me.Height) / 2)
 Me.Left = Int((Screen.Width - Me.Width) / 2)
End Sub

Sub LoadTaskList()
 Dim CurrWnd As Long
 Dim LongueurDeLeNom As Long
 Dim TaskName As String
 Dim Parent As Long

 CurrWnd = RecupLaFenetre(Form1.hwnd, 0)
 gIndex = 0
 While CurrWnd <> 0
  Parent = RecupLePidDuPapa(CurrWnd)
  LongueurDeLeNom = RecupLaLongueurDeLeTexte(CurrWnd)
  TaskName = Space$(LongueurDeLeNom + 1)
  Length = RecupLeTexte(CurrWnd, TaskName, LongueurDeLeNom + 1)
  TaskName = Left$(TaskName, Len(TaskName) - 1)
  If Length > 0 And gIndex < 200 Then
   If TaskName <> Me.Caption Then List1.AddItem TaskName
   IWanaKeepItSomewhere$(gIndex) = CurrWnd
   gIndex = gIndex + 1
  End If
  CurrWnd = RecupLaFenetre(CurrWnd, 2)
  DoEvents
 Wend
End Sub

Private Sub List1_Click()
 Text1.text = List1.List(List1.ListIndex)
End Sub

Conclusion :


<IMG SRC='http://manipulator.free.fr/captures/rename.jpg' WIDTH=448 HEIGHT=265>

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.