cs_veler
Messages postés723Date d'inscriptiondimanche 26 novembre 2006StatutMembreDernière intervention23 janvier 2013
-
9 mars 2009 à 11:55
cs_veler
Messages postés723Date d'inscriptiondimanche 26 novembre 2006StatutMembreDernière intervention23 janvier 2013
-
9 mars 2009 à 12:44
Salut !
J'ai une application utilisant Directx. Je la lance et aimerais qu'elle soit une enfant (si possible MDI) de ma Form actuel.
Pour ça, j'ai le code suivant :
Dim hInst, hWndApp As Integer
Dim procap As New Process
Dim nomproc As String
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hInst = Shell(Application.StartupPath & "\Temp.exe", AppWinStyle.Hide) 'lance notepad et récup de l'Id
procap = Process.GetProcessById(hInst) 'Retourne un nouveau composant Process, en fonction de l'identificateur de notepad
hWndApp = procap.MainWindowHandle 'récup de l'handle
nomproc = procap.MainWindowTitle 'récup du titre -- inutile--
procap.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
SetParent(hWndApp, Me.Handle.ToInt32)
procap.StartInfo.WindowStyle = ProcessWindowStyle.Normal
End Sub
Ca fonctionne très bien avec une application tel que le Notepad, par contre, avec mon application Directx (qui est faite avec Dark Basic Pro), bin ça marche.
cs_veler
Messages postés723Date d'inscriptiondimanche 26 novembre 2006StatutMembreDernière intervention23 janvier 20132 9 mars 2009 à 12:44
Re !
Bon, j'ai un peu avancé !
Le problème vient sûrement de hWndApp . La valeur est fausse. La valeur est 0, alors qu'en réalité c'est 1400 et quelque, enfin bref, c'est incorrecte.