我以前编程的一个程序代码丢了,急啊...我想把以前的运行程序嵌入到我现在的VB程序窗体中,请问如何解决?
解决方案 »
- VB基础问题。打开项目出错我要怎么办?
- 使用SetParent加入Excel不能编辑
- 如果我要建一个二叉树(数据结构的,不是控件)
- ******* 关于 IMAGE 控件 *******
- 又有问题要麻烦高手了?(记录修改问题)
- 下面这段代码,怎么获得BACKGROUND的图片,目前只能获得img
- Microsoft Jet 数据库引擎打不开文件''。 它已经被别的用户以独占方式打开,或没有查看数据的权限。
- 大家看看这个怎么实现?数shu=5000,现在要将转化为十六进制数,以一个字节为单位,逆序放入数组里面(byte型),请问这怎么实现?
- 呵呵~mostar转游转游又来提几个问题,谢谢参与:)
- 在Form上放一位图,如何使其实现象桌面桌布一样的平铺功能(即使其平铺满整个窗口)?
- Excel的ADO连接问题
- 问一个与数组有关的问题(在线等候……)
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate old_parent As Long
Private child_hwnd As Long' Return the window handle for an instance handle.
Private Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long
Dim test_pid As Long
Dim test_thread_id As Long ' Get the first window handle.
test_hwnd = FindWindow(ByVal 0&, ByVal 0&) ' Loop until we find the target or we run out
' of windows.
Do While test_hwnd <> 0
' See if this window has a parent. If not,
' it is a top-level window.
If GetParent(test_hwnd) = 0 Then
' This is a top-level window. See if
' it has the target instance handle.
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid) If test_pid = target_pid Then
' This is the target.
InstanceToWnd = test_hwnd
Exit Do
End If
End If ' Examine the next window.
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End FunctionPrivate Sub cmdFree_Click()
SetParent child_hwnd, old_parent cmdRun.Enabled = True
cmdFree.Enabled = False
End SubPrivate Sub cmdRun_Click()
Dim pid As Long
Dim buf As String
Dim buf_len As Long
Dim styles As Long ' Start the program.
pid = Shell(txtProgram.Text, vbNormalFocus)
If pid = 0 Then
MsgBox "Error starting program"
Exit Sub
End If ' Get the window handle.
child_hwnd = InstanceToWnd(pid) ' Reparent the program so it lies inside
' the PictureBox.
old_parent = SetParent(child_hwnd, MDIForm1.hwnd) cmdRun.Enabled = False
cmdFree.Enabled = True
End Sub