Ouvrir exe dans un picturebox

Résolu
cs_amita Messages postés 151 Date d'inscription samedi 17 juillet 2004 Statut Membre Dernière intervention 11 mai 2012 - 9 nov. 2006 à 13:32
olixelle Messages postés 506 Date d'inscription vendredi 30 juillet 2004 Statut Membre Dernière intervention 3 mars 2008 - 28 nov. 2006 à 15:48
salut les ami(e)s

voila je veux ouvrir un exe dans un picturebox sans que le form soi de type MDIFORM ,je veux louvrir  dans un form normal 

11 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
9 nov. 2006 à 18:21
salut,

met une picturebox assez grande sur une form assez grande....

Option Explicit
'
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 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()
    'KPD-Team 1999
    'URL:
http://www.allapi.net/
    'E-Mail:
KPDTeam@Allapi.net
    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, Picture1.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 Sub

<small>Coloration
syntaxique automatique [AFCK] </small>
       

++
PCPT   [AFCK]
<hr size ="2" width="100%" />Prenez un instant pour répondre à ce sondage svp
3
jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 27
9 nov. 2006 à 14:35
Slut l' ami(e)
Une précision : tu veux ouvrir comment et quoi exactement ?
L'exécuter ? L'ouvrir en binaire ?
Tu connais les objets OLE ?
0
cboulas Messages postés 2641 Date d'inscription mercredi 2 juin 2004 Statut Membre Dernière intervention 8 janvier 2014 16
9 nov. 2006 à 16:53
Salut, si ton fichier as l'extension EXE mais contient une image, oui c'est faisable, si c'est une image dans un EXE : il faut pouvoir l'extraire, si tu veux ouvrir un exe avec un picturebox : Shell(...)

Chris...
Web : Firstruner
0
cs_amita Messages postés 151 Date d'inscription samedi 17 juillet 2004 Statut Membre Dernière intervention 11 mai 2012
14 nov. 2006 à 15:25
merci cher ami pour votre explication

just est ce possible de ramner cet exe dans un top et left defini
merci
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
14 nov. 2006 à 15:45
salut,

l'API SetWindowPos est faite aussi pour çà

exemple :

Option Explicit
'
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As
Long, ByVal Y As Long,
ByVal cx As Long, ByVal cy As
Long, ByVal wFlags As Long)
'
Private Sub Command1_Click()
'   on déplace
en
'   left 200
'  
top 300
'   width 640
'   height 480
    Call SetWindowPos(Me.hWnd, 0&, 200, 300, 640, 480, 0&)
End Sub

<small>Coloration
syntaxique automatique [AFCK]</small>
       

là tu n'as plus qu'à remplacer ton Me.hWnd par mWnd à mettre en fin de Form_Load
ps : l'API LockWindowUpdate est ici utilisée que pour l'exemple avec le bloc-note... à adapter donc (t'en a normalement pas besoin)

++
<hr size="2" width="100%" />Prenez un instant pour répondre à ce sondage svp
0
cs_amita Messages postés 151 Date d'inscription samedi 17 juillet 2004 Statut Membre Dernière intervention 11 mai 2012
20 nov. 2006 à 18:16
merci cher ami  pour ton effort

mais le pblm que cet commande me ramene mon form parent a une position precise, je veux que mon exe soit ramener a une postion left =0 et top=0 dans le picturebox.

svp aidez moi car vraiment je suis bloque
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
21 nov. 2006 à 20:47
tu as les positions en commentaires.
tu connais le left et le top de ta form, le left et top de ta picturebox

pour l'exemple, il suffit de remplacer 200 par ces left additionnés.

<hr size="2" width="100%" />Prenez un instant pour répondre à ce sondage svp
0
BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
28 nov. 2006 à 08:14
Bonjour,

Le code ici correspond parfaitement à mes besoins, mais je n'arrive pas a l'adapter a VB.NET.
J'arrive a le faire executer sans probleme, mais mon notepad reste independant de ma picture.
Comment faire fonctionner SetParent en VB.Net avec des application externe ?
SetParent a l'air de pourtant bien fonctionner entre 2 form VB. 
j'avouerai que ca fait 2 jours que je suis dessus et que je suis toujours sans reponse.

++

BasicInstinct
0
olixelle Messages postés 506 Date d'inscription vendredi 30 juillet 2004 Statut Membre Dernière intervention 3 mars 2008 2
28 nov. 2006 à 14:04
comment as tu déclaré setparent dans ton code ?

Rollerman
0
BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
28 nov. 2006 à 15:02
tout simplement

Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer







BasicInstinct
0
olixelle Messages postés 506 Date d'inscription vendredi 30 juillet 2004 Statut Membre Dernière intervention 3 mars 2008 2
28 nov. 2006 à 15:48
essayes ca:

Declare Function SetParent Lib "user32" (ByVal hWndChild As intptr, ByVal hWndNewParent As intptr) As Integer

Rollerman
0
Rejoignez-nous