多文档问题,高分,在线等待!!!

zhangsp 2003-10-18 02:07:30
在VB中实现多文档结构程序时,可不可以将MDI Child窗体放入在其它的DLL中而中MDI from中调用不同DLL的不同MDI child。如果可以,如何实现。
...全文
31 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangsp 2003-10-20
  • 打赏
  • 举报
回复
up
flc 2003-10-19
  • 打赏
  • 举报
回复
xuexi
zhangsp 2003-10-18
  • 打赏
  • 举报
回复
rainstormmaster,你的方法是否适用于我在一个主工程中引用另几个Active Dll,MDI form在主工程中,MDI child在Active DLL中。此时MDI child的窗口句柄好象还没有吧?
zhangsp 2003-10-18
  • 打赏
  • 举报
回复
我顶,我顶,我顶项顶!!!
rainstormmaster 2003-10-18
  • 打赏
  • 举报
回复
一个例子:
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()
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
zhangsp 2003-10-18
  • 打赏
  • 举报
回复
rainstormmaster,能具体一点说明吗?
rainstormmaster 2003-10-18
  • 打赏
  • 举报
回复
findwindow后setparent
zhangsp 2003-10-18
  • 打赏
  • 举报
回复
楼上的,你没有理解我的意思,我的意思是如何在MDI程序中调用其它DLL中的MDI child,而不是本工程中的MDI child。
射天狼 2003-10-18
  • 打赏
  • 举报
回复
添加窗口->添加MDI窗口->将子窗口的MDICHILD属性设置为TRUE就可以了~
zhangsp 2003-10-18
  • 打赏
  • 举报
回复
是不是有难度,怎没有人回答啊,顶一下。

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧