让别的程序在你的窗口里运行

引用内容 引用内容

'本示例演示把指定名称的任意窗体包容进来.
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




文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: VB
评论: 2 | 引用: 0 | 查看次数: -
回复回复JiaJia[2007-11-18 00:30 AM | del]
SetParent 设置父子关系,也就是传说中的“插入”
回复回复siLence_Again[2007-11-17 08:02 PM | del]
SetParent  hoho
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.