Results 1 to 4 of 4

Thread: Opening exe inside vb.net form

  1. #1
    New Member
    Join Date
    Jul 12
    Posts
    2

    Opening exe inside vb.net form

    Hi,
    I'm having a little trouble when trying to open executables and set them in a panel in my form.

    Currently I have:
    VB.net Code:
    1. Imports System.Diagnostics.Process
    2. Imports System.Runtime.InteropServices
    3.  
    4. Public Class Form1
    5.     Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    6.     Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    7.     Private Const WM_SYSCOMMAND As Integer = 274
    8.     Private Const SC_MAXIMIZE As Integer = 61488
    9.     Private proc As Process = New Process()
    10.  
    11. Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    12.     proc = Process.Start("notepad.exe")
    13.     proc.WaitForInputIdle()
    14.     SetParent(proc.MainWindowHandle, Panel1.Handle)
    15.     SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
    16.     End Sub
    17.  
    18. End Class

    what throws me is that the code works when i use "notepad.exe" but no other executable say mspaint or another windows an help will be appriciated!

  2. #2
    Junior Member
    Join Date
    Jul 12
    Location
    Here
    Posts
    18

    Re: Opening exe inside vb.net form

    Try this thread, i saw it yesterday on the forum.

    http://www.vbforums.com/showthread.php?t=684771

  3. #3
    New Member
    Join Date
    Jul 12
    Posts
    2

    Re: Opening exe inside vb.net form

    Thanks that helped a lot. Now the only problem that the application is free moving around the parent app. Is there a way to anchor it to the page?

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 12
    Posts
    5,966

    Re: Opening exe inside vb.net form

    Yup. Maximise! That's also covered in the other thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •