Handle d'un programme

kev900001 Messages postés 119 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 9 avril 2008 - 2 déc. 2007 à 15:12
kev900001 Messages postés 119 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 9 avril 2008 - 13 déc. 2007 à 17:25
bonjour,
je suis en train de faire un programme de navigation avec plusieurs forms
mais j'utilise un logiciel dont je nai pas acces au code et jaimerai losque je lappel a laide de mon command1 quil soit uniquement a  l'interieur d'une picture box et quil ne puisse pas en sortir
merci de votre aide

5 réponses

jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 27
2 déc. 2007 à 15:20
"mais j'utilise un logiciel dont je nai pas acces au code et jaimerai losque je lappel a laide de mon command1 qu'il soit uniquement a  l'interieur d'une picture box et qu'il ne puisse pas en sortir "

Les mots ont leur importance (surtout en matière de développement)..
Je te suggère donc d'apporter toi-même la correction nécessaire à ce que tu as écrit là.
On commence par cette précision élémentaire d'expression et on continue ensuite (du moins en ce qui me concerne).
0
jmfmarques Messages postés 7666 Date d'inscription samedi 5 novembre 2005 Statut Membre Dernière intervention 22 août 2014 27
2 déc. 2007 à 15:21
Et ce :
d'autant que la précision est le début de la réponse; hein ... (handle de quoi, déjà ?)
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
2 déc. 2007 à 15:58
"mettre le logiciel dans une picture box..."
c'est pourtant clair jmf, il faut afficher le code binaire de l'exe dans la picturebox.

ciao...
BruNews, MVP VC++
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
2 déc. 2007 à 16:48
salut,

il faut changer le parent de ton appli (qui n'a pas de handle!!)

exemple de l'API-Guid :

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()
    '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, 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

++
PCPT  [AFCK]
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
0

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

Posez votre question
kev900001 Messages postés 119 Date d'inscription mercredi 7 juillet 2004 Statut Membre Dernière intervention 9 avril 2008
13 déc. 2007 à 17:25
 merci PCPT
sa marche bien pour le notepad mais helas sa ne fonctionne pas avec mon logiciel il se lance bien mais il reste en dehors  de ma form1
0
Rejoignez-nous