F
flak_jack
Guest
Hi All,
Fairly new to VB.Net, having worked with Macs for the last ten years but enjoying it so far.
I'm trying to get an external program window to display within a windows form panel for a proof of concept project I'm working on for a single user desktop (idea is to do it properly with ActiveX or rebuilding the external program in a browser if we get approval/resource to go ahead).
The code below works for Chrome providing the user doesn't already have an instance open but I have two issues:
1) the content is not scaling to the panel size (though things like Wordpad or Notepad do)
2) Any program that takes a while to load or has a splash screen or multiple windows isn't working and just opens outside of my form
What I have tried:
Hide Copy Code
Option Strict On
Option Explicit On
Imports System.Threading
Public Class Form1
Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
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
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE As Integer = 61488
Dim proc As Process
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
proc = Process.Start("Chrome.exe")
proc.WaitForInputIdle()
proc.WaitForExit(1000)
SetParent(proc.MainWindowHandle, Panel1.Handle)
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class
Continue reading...