XIIX
Messages postés17Date d'inscriptionmercredi 20 décembre 2006StatutMembreDernière intervention22 mai 2011
-
14 oct. 2007 à 16:13
GEDDi
Messages postés206Date d'inscriptionlundi 22 novembre 1999StatutMembreDernière intervention 3 juillet 2008
-
14 oct. 2007 à 22:09
Salutation,
Une petite question .
Comment ont fait pour intégré une Application EXE a l'interieur d'un From ?
exemple: Un From Normal avec a l'interieur Firefox
C'est pour pouvoir ajouter une application qui n'a pas de ControlBox de pouvoir en Rajouter une voila
Merci
GEDDi
Messages postés206Date d'inscriptionlundi 22 novembre 1999StatutMembreDernière intervention 3 juillet 2008 14 oct. 2007 à 21:27
Yop !
Essayes ceci : ( ça va mettre Notepad dans ta Form courante )
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Const GW_HWNDNEXT = 2
Dim mWnd As Long
Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
'Find the first window
test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
Do While test_hwnd <> 0
'Check if the window isn't a child
If GetParent(test_hwnd) = 0 Then
'Get the window's thread
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
'retrieve the next window
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function
Private Sub Form_Load()
Dim Pid As Long
'Lock the window update
LockWindowUpdate GetDesktopWindow
'Execute notepad.Exe
Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
If Pid = 0 Then MsgBox "Error starting the app"
'retrieve the handle of the window
mWnd = InstanceToWnd(Pid)
'Set the notepad's parent
SetParent mWnd, Me.hwnd
'Put the focus on notepad
Putfocus mWnd
'Unlock windowupdate
LockWindowUpdate False
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Unload notepad
DestroyWindow mWnd
'End this program
TerminateProcess GetCurrentProcess, 0
End Sub
XIIX
Messages postés17Date d'inscriptionmercredi 20 décembre 2006StatutMembreDernière intervention22 mai 2011 14 oct. 2007 à 18:21
Re,
Ok Merci ,Mais je n'est jamais Utiliser le Hwnd je sais juste que sa a un rapport avec les APIs Windows mais vraiment jamais servi vous n'avais pas un Tuyau ?
Pour le SetParent je vais voir si je trouve une façon de L'utilisé :)
Sinon Merci !
~~XIIX IN PROGRESS~~
Ps:Je vien de commencer a apprendre pour ca (vive le N00B ^^)
XIIX
Messages postés17Date d'inscriptionmercredi 20 décembre 2006StatutMembreDernière intervention22 mai 2011 14 oct. 2007 à 21:50
Merci pour le Code il marche tres bien Cependant j'ai un autre probleme
Notepad Ok mais si c'est internet explorer par exemple sa marche pas ou meme un autre projet VB6 comment sa se fait ?
~~XIIX IN PROGRESS~~
Vous n’avez pas trouvé la réponse que vous recherchez ?
GEDDi
Messages postés206Date d'inscriptionlundi 22 novembre 1999StatutMembreDernière intervention 3 juillet 2008 14 oct. 2007 à 22:09
Ben dans ce cas il faut chopper le Hwnd de l'application qui tourne déjà par un FindWindow, ensuite tu appliques un coup de SetParent mWnd, Me.hwnd tout betement ! :)