所以我有一种方法可以将Powerpoint集成到面板中。我使用FindWindow和SetParent函数来实现这一点:
Dim proc as integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
Private Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Public Sub embed_Window()
Do Until proc <> 0
proc = FindWindow(vbNullString, window_name)
Loop
SetParent(proc, Panel1.Handle)
End Sub
该部分可以将另一个窗口嵌入到我的面板控件中。我的问题是,如何关闭面板中的窗口?我不再可以使用FindWindow方法,因为它不再是任务栏中的窗口。
答案 0 :(得分:0)
要关闭打开的窗口,您需要使用PostMessage:
Private Declare Auto Function PostMessage Lib "user32" (ByVal hwnd As Integer, ByVal message As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Boolean
Public Const WM_CLOSE = &H10
Public Sub CloseWindow()
PostMessage(proc, WM_CLOSE, 0, 0)
End Sub