2012-01-05 79 views
0

我正在開發一個項目以在Panel中嵌入另一個程序。我得到這個工作,但我似乎無法將窗口放在窗體的內部。移動另一個程序的窗口並刪除邊框

圖片:

enter image description here

我使用的MoveWindow和SetWindowLong函數與至今沒有運氣..這是我的onload事件;

Dim proc As Process = Process.Start("C:\Nexon\MapleStory\MapleStory.exe", "GameLaunching") 
proc.WaitForInputIdle() 
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND2, SC_CLOSE, 0) 

System.Threading.Thread.Sleep(5000) 
Do 
    System.Threading.Thread.Sleep(5000) 
Loop Until FindWindow("MaplestoryClass", Nothing) 
System.Threading.Thread.Sleep(500) 

SetWindowLong(Processes(0).MainWindowHandle, GWL_STYLE, WS_VISIBLE) 

MoveWindow(Processes(0).MainWindowHandle, Panel1.Left, Panel1.Top, Panel1.Right, Panel1.Bottom, True) 

Dim FHandle As IntPtr 
FHandle = FindWindow("MaplestoryClass", Nothing) 
SetParent(FHandle, Panel1.Handle) 

我需要找到一種方法,等到程序的窗口已經顯示出,然後執行的MoveWindow和SetWindowLong函數事件..

+0

有你試圖最大化楓葉故事窗口? – broke 2012-01-05 18:12:19

+0

這不起作用,因爲它被禁用 – 2012-01-06 03:16:17

回答

0

我覺得我得到它:

[DllImport("user32.dll")] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); 
[DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); 
[DllImport("user32.dll")] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); 

Process p = new Process(); 
p.StartInfo.FileName = "programPath"; 
p.Start(); 
p.WaitForInputIdle(); 

SetParent(p.MainWindowHandle, Panel1.Handle); 
SetWindowLong(p.MainWindowHandle, -16, 0x10000000); 
ShowWindow(p.MainWindowHandle, 3); 
相關問題