VB控制子窗体(外部程序)在Picture控件上
2008-11-21 22:01
357 查看
在VB新建一工程,有两个窗体,FORM1,FORM2
FORM1有一个PIC控件和一个按钮控件
代码如下:
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CLIPSIBLINGS = &H4000000
Private Const WS_VISIBLE = &H10000000
Private Sub Command1_Click()
Dim handle As Long, Ret As Long
'获取窗体句柄
handle = Form2.hwnd
' handle =FindWindow(vbNullString, "TheWorld") '示例手工输入外部窗体标题,如记事本
Ret = SetWindowLong(handle, GWL_STYLE, WS_VISIBLE Or WS_CLIPSIBLINGS)
'插入指定的窗体
SetParent handle, Picture1.hwnd
Form2.Move Picture1.ScaleLeft, Picture1.ScaleTop
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
FORM1有一个PIC控件和一个按钮控件
代码如下:
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CLIPSIBLINGS = &H4000000
Private Const WS_VISIBLE = &H10000000
Private Sub Command1_Click()
Dim handle As Long, Ret As Long
'获取窗体句柄
handle = Form2.hwnd
' handle =FindWindow(vbNullString, "TheWorld") '示例手工输入外部窗体标题,如记事本
Ret = SetWindowLong(handle, GWL_STYLE, WS_VISIBLE Or WS_CLIPSIBLINGS)
'插入指定的窗体
SetParent handle, Picture1.hwnd
Form2.Move Picture1.ScaleLeft, Picture1.ScaleTop
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
相关文章推荐
- 窗体内嵌外部程序的显示,获取控件的图片
- C#Windows窗体程序:用trackBar控件制作调色板
- 如何控制其他程序窗体上的窗口控件:下
- delphi 程序窗体及控件自适应分辨率(通过ComponentCount遍历改变字体大小以及上下左右)
- 如何控制其他程序窗体上的窗口控件(中)
- Delphi中如何控制其他程序窗体上的窗口控件
- 如何控制其他程序窗体上的窗口控件:上
- 创建一个如下的窗体,并在窗体上放置colorDialog控件。实现功能:1)程序运行时,单击打开颜色对话框按钮,可选择颜色,并以所选颜色作为窗体背景色
- C++/CLI 窗体程序通过空间的name操纵控件
- c#窗体程序之tooltip控件显示鼠标位置
- C# 窗体边角圆弧处理及在C#中调用外部程序(执行批处理,打开窗口等)
- windows窗体程序中使用WPF控件 Host WPF Controls in Windows Forms Application
- 如何控制其他程序窗体上的窗口控件:中
- <转> VS.NET开发小技巧——C/S程序中MDI子窗体控制其父窗体控件
- 在窗体上放置saveFileDialog、openFileDialog两个控件。实现功能:1)程序运行时,在文本框(注意文本框多行、带垂直滚动条)中输入汉字、字符等,单击保存按钮,即可将文本框中内容保
- VTK-MFC程序 picture控件
- 获得其他程序窗体控件中的信息
- PNG透明窗体全攻略(控件不透明)vc++程序指导
- 为Office文档添加Windows窗体控件:在运行时向应用程序级外接程序中添加控件
- 外部启动c#窗体程序传参问题