VB代码:
Dim ChildBtnCombo As Long, ChildBtnQuery As Long, ChildBtnDelete As Long, ChildBtnClear As Long, ChildBtnExit As Long
Public Sub Init()
'用VB的Shell语句启动软件,并得到该软件的pID
idProc = Shell(软件A的路径, 1)
'AppActivate idProc '激活该软件
'根据pid得到hwnd
windowHandle = GetWinHandle(idProc)
If windowHandle <= 0 Then Call ShowErr("windowHandle")
'根据hwnd,放入自身窗体
SetParent windowHandle, Me.hwnd
Dim s As String, ret As Long, hwnd1 As Long
'查找下拉框,保存句柄备用
ChildBtnCombo = FindWindowEx(windowHandle, 0, "ComboBox", vbNullString)
If ChildBtnCombo <= 0 Then Call ShowErr("ComboBox")
'查找几个按钮,保存句柄备用
hwnd1 = 0
s = String(255, 0)
Do
hwnd1 = FindWindowEx(windowHandle, hwnd1, "Button", vbNullString)
ret = GetWindowText(hwnd1, s, 255)
If ret > 0 Then
If InStr(s, "查 找") Then ChildBtnQuery = hwnd1
If InStr(s, "删 除") Then ChildBtnDelete = hwnd1
If InStr(s, "清 空") Then ChildBtnClear = hwnd1
If InStr(s, "退 出") Then ChildBtnExit = hwnd1
s = String(255, 0)
End If
Loop Until hwnd1 = 0
If ChildBtnQuery <= 0 Then Call ShowErr("windowHandle")
If ChildBtnDelete <= 0 Then Call ShowErr("windowHandle")
If ChildBtnClear <= 0 Then Call ShowErr("windowHandle")
If ChildBtnExit <= 0 Then Call ShowErr("windowHandle")
'修改窗体样式,去边框和标题栏
Dim lStyle As Long, lExStyle As Long, lRect As rect, meRect As rect
Call GetWindowRect(windowHandle, lRect)
lStyle = GetWindowLong(windowHandle, GWL_STYLE)
lExStyle = GetWindowLong(windowHandle, GWL_EXSTYLE)
lStyle = lStyle And Not WS_CAPTION
lStyle = lStyle And Not WS_BORDER
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_THICKFRAME
lStyle = lStyle And Not WS_OVERLAPPED
'lStyle = lStyle Or WS_CLIPSIBLINGS
'lStyle = lStyle Or WS_CLIPCHILDREN
'lStyle = lStyle And Not WS_TILEDWINDOW
SetWindowLong windowHandle, GWL_STYLE, lStyle '设置新的lStyle风格
'Call MoveWindow(windowHandle, 0, 0, lRect.Right - lRect.Left, lRect.Bottom - lRect.Top, 1)
Call SetWindowPos(windowHandle, vbNull, 0, 0 + 25, lRect.Right - lRect.Left, lRect.Bottom - lRect.Top, SWP_FRAMECHANGED)
lExStyle = lExStyle And Not WS_EX_WINDOWEDGE
lExStyle = lExStyle And Not WS_EX_CLIENTEDGE
lExStyle = lExStyle And Not WS_EX_DLGMODALFRAME
SetWindowLong windowHandle, GWL_EXSTYLE, lExStyle '设置新的lExStyle风格
'Call MoveWindow(windowHandle, 0, 0, lRect.Right - lRect.Left, lRect.Bottom - lRect.Top, 1)
Call SetWindowPos(windowHandle, vbNull, 0, 0 + 25, lRect.Right - lRect.Left, lRect.Bottom - lRect.Top, SWP_FRAMECHANGED)