一个exe工程 ,有一个form窗体,叫form1,form1上有个按钮command1,还有一个picture box,目的是当作其他窗体的容器;新增加一个active dll工程,在这个工程中新增一个窗体form2。我想通过单击form1上的command1,来把form2加载到form1中的picture box中,应该怎么做呢?
解决方案 »
- 关于webbrowser控件的难题,分不多,请大侠帮忙
- mshflexgrid在设计阶段能设置其表头的字段名和类型信息吗?是否必须用代码?
- 这个功能该如何实现呢?sql
- 成都欣逢软件开发有限公司 高薪招聘VB高手
- 比较特别的问题,示解决方法或思路
- 有一套VB写的进销存管理软件放到网上让大家下,共同交流共同进步
- 本人用VB中自带的打包程序做出来的安装文件有好几个M,而直接生成EXE文件才几百个K,我看了一下,几个DLL文件就好几百K了,不知道各位是
- 复杂问题:我在线等候
- 如何实现字库优先?谢!!!
- 怎样能使窗口总在最前
- 如何编辑WebBrowser控件
- 在picture box控件中有没有调整图片大小的方法
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()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
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
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long比如要把form2放到form1的picture1中(form1已经显示):
load form2
SetParent form2.hwnd,form1.picture1.hwnd即可
我想你误会我的意思了,我不是把外部程序比如notepad.exe放入我的form1中的picturebox容器中,而是要把一个active dll工程的一个form放入到exe工程中的form1的picturebox中!
反正你要把一个form放入到exe工程中的form1的picturebox中,是肯定会用到SetParent 的
Public Sub showReg(frm As Form)
'codes
End Sub错误是:private object modules cannot be used in public object modules as parameters or return types for public procedures, ...