Ouvrir une appli en .exe dans une form en vb6

Description

Bonjour,

J'avais proposé ce code comme solution dans le forum.

Il est destiné à tous ceux qui veullent ouvrir une appli en .exe dans une Form en vb6

Si c'est possible, proposer un code en VB2005.

Source / Exemple :


'Dans un module :

Public Const GW_HWNDNEXT = 2
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _
                        ByVal hWndNewParent As Long) As Long
Public Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, _
  ByVal wCmd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" _
  (ByVal hWnd As Long, lpdwprocessid As Long) As Long
Function ProcIDFromWnd(ByVal hWnd As Long) As Long
   Dim idProc As Long
   GetWindowThreadProcessId hWnd, idProc
   ProcIDFromWnd = idProc
End Function
Function GetWinHandle(hInstance As Long) As Long
   Dim tempHwnd As Long
   tempHwnd = FindWindow(vbNullString, vbNullString)
   Do Until tempHwnd = 0
      If GetParent(tempHwnd) = 0 Then
         If hInstance = ProcIDFromWnd(tempHwnd) Then
            GetWinHandle = tempHwnd
            Exit Do
         End If
      End If
      tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT)
   Loop
End Function

'Dans la fenêtre mère :

Private Sub MDIForm_Load()
    Dim hInst As Long, hWndApp As Long
    hInst = Shell("notepad.exe")
    hWndApp = GetWinHandle(hInst)
    SetParent hWndApp, Me.hWnd
End Sub

'Bon courage et bonne chance

Codes Sources

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.