Forum > Visual Basic 6
J'aimerais aussi afficher cette form à l'aide d'un bouton dans une autre application VB6.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionconstituée d'une FORM qui lit des données sur mon réseau et les intègres à intervalles réguliers?
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hWnd As Long, ByVal param As Long) As Long Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd 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 IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Public Const SW_SHOW = 5 Sub Bouton1_Clic() Handle = Application.hWnd Dim strtmp As String NewHandle = Handle For sens = 2 To 3 Do Handle = NewHandle strtmp = Space(100) r = GetWindowText(Handle, strtmp, 100) nom = strtmp If Left(nom, 8) = "Ctrl_PV2" Then result = ShowWindow(Handle, SW_SHOW) ' Stop Exit Sub End If NewHandle = GetNextWindow(Handle, sens) Loop Until Handle = NewHandle Next 100 'suite - On lance l'appli si elle n'est pas en service fichier = Shell(ThisWorkbook.Path & "\Ctrl_PV2.exe", 1) End Sub Sub Bouton2_Click() Dim hWnd As Long Dim Titre_Fenetre As String * 255 Dim TitreFen As String Dim j As Long ' on teste les fenêtres hWnd = GetWindow(GetDesktopWindow(), 5) Do While (Not IsNull(hWnd)) And (hWnd <> 0) Titre_Fenetre = String(255, 0) ret = GetWindowText(hWnd, Titre_Fenetre, 255) If Titre_Fenetre <> String(255, 0) Then If IsWindowVisible(hWnd) = 1 Then TitreFen = Titre_Fenetre TitreFen = Left(TitreFen, ret) j = j + 1 If Val(j) < 10 Then j = "0" & j ' Insère le résultat de la recherche dans la feuille Excel Sheets(1).Range("E" & j).FormulaR1C1 = TitreFen Sheets(1).Range("F" & j).FormulaR1C1 = hWnd End If End If hWnd = GetWindow(hWnd, 2) 'cherche la fenêtre suivant Loop End Sub
J'utilise la commande GetWindow , mais je vois que tu parle de FindWindow. Mon problème est peut-être de ce coté !!
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Const SW_SHOW = 5 Sub Bouton1_Clic() Dim Handle, result 'Cherche le Handle de la Fenêtre Handle = FindWindow(vbNullString, "Suivi des Evenements d'Exploitation.") If Handle <> 0 Then result = ShowWindow(Handle, SW_SHOW) Exit Sub End If 100 'suite - On lance l'appli si elle n'est pas en service fichier = Shell(ThisWorkbook.Path & "\Ctrl_PV2.exe", 1) End Sub