让别的程序在你的窗口里运行,设置父窗口。

'本示例演示把指定名称的任意窗体包容进来.
Option Explicit

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 Declare Function
SetParent Lib "user32" ( ByVal hWndChild As Long , ByVal hWndNewParent As Long ) As Long
Private Declare Function
MoveWindow Lib "user32" ( ByVal hWnd As Long , ByVal X As Long , ByVal Y As Long , ByVal nWidth As Long , ByVal nHeight As Long , ByVal bRepaint As Long ) As Long
Private Declare Function
GetForegroundWindow Lib "user32" () As Long

Private Const
GWL_STYLE = (- 16 )
Private Const WS_CLIPSIBLINGS = &H4000000
Private Const WS_VISIBLE = &H10000000


Private Sub Form_Load()
Dim Handle As Long , Ret As Long
'根据窗口标题获取窗体句柄
Handle = FindWindow(vbNullString, "好无聊哇!" )
If Handle = 0 Then Exit Sub
Ret = SetWindowLong(Handle, GWL_STYLE, WS_VISIBLE Or WS_CLIPSIBLINGS)
'插入指定的窗体
SetParent Me.hWnd, Handle
Form1.Move
4000 , 5000 , 320 , 320
End Sub

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值