是MDI 吗?MDI 可用这个函数得到子窗体的hWnd EnumChildWindows VB声明 Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long 说明 为指定的父窗口枚举子窗口 返回值 Long,非零表示成功,零表示失败 参数表 参数 类型及说明 hWndParent Long,欲枚举子窗口的父窗口的句柄 lpEnumFunc Long,为每个子窗口调用的函数的指针。用AddressOf运算符获得函数在一个标准模块中的地址 lParam Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的。(原文:Value that is passed to the EnumWindows event of the dwcbkd32.ocx custom control during enumeration. The meaning of this value is defined by the programmer.) 注解 在vb4下要求dwcbkd32.ocx定制控件。子窗口下属的子窗口也可由这个函数枚举
Const WS_CHILD = &H40000000 Const WM_LBUTTONDOWN = &H201 Const WM_LBUTTONUP = &H202 Const SW_HIDE = 0 Const SW_NORMAL = 1 Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Dim tWnd As Long, bWnd As Long, ncWnd As Long Private Sub Form_Load() Dim R As RECT 'Get the taskbar's window handle tWnd = FindWindow("Shell_TrayWnd", vbNullString) 'Get the start-button's window handle bWnd = FindWindowEx(tWnd, ByVal 0&, "BUTTON", vbNullString) 'Get the start button's position GetWindowRect bWnd, R 'Create a new button ncWnd = CreateWindowEx(ByVal 0&, "BUTTON", "Hello !", WS_CHILD, 0, 0, R.Right - R.Left, R.Bottom - R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&) 'Show our button ShowWindow ncWnd, SW_NORMAL 'Hide the start button ShowWindow bWnd, SW_HIDE End Sub Private Sub Form_Unload(Cancel As Integer) 'show the start button ShowWindow bWnd, SW_NORMAL 'destroy our button DestroyWindow ncWnd End Sub
Declare Function EnumChildWindows Lib "user32" Alias "EnumChildWindows" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
说明
为指定的父窗口枚举子窗口
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
hWndParent Long,欲枚举子窗口的父窗口的句柄
lpEnumFunc Long,为每个子窗口调用的函数的指针。用AddressOf运算符获得函数在一个标准模块中的地址
lParam Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的。(原文:Value that is passed to the EnumWindows event of the dwcbkd32.ocx custom control during enumeration. The meaning of this value is defined by the programmer.)
注解
在vb4下要求dwcbkd32.ocx定制控件。子窗口下属的子窗口也可由这个函数枚举
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const SW_HIDE = 0
Const SW_NORMAL = 1
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim tWnd As Long, bWnd As Long, ncWnd As Long
Private Sub Form_Load()
Dim R As RECT
'Get the taskbar's window handle
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
'Get the start-button's window handle
bWnd = FindWindowEx(tWnd, ByVal 0&, "BUTTON", vbNullString)
'Get the start button's position
GetWindowRect bWnd, R
'Create a new button
ncWnd = CreateWindowEx(ByVal 0&, "BUTTON", "Hello !", WS_CHILD, 0, 0, R.Right - R.Left, R.Bottom - R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&)
'Show our button
ShowWindow ncWnd, SW_NORMAL
'Hide the start button
ShowWindow bWnd, SW_HIDE
End Sub
Private Sub Form_Unload(Cancel As Integer)
'show the start button
ShowWindow bWnd, SW_NORMAL
'destroy our button
DestroyWindow ncWnd
End Sub
看不出它有什么特征, 只知道它的标题栏是蓝色的, 别的窗体都是灰色的, 而且那个蓝色的窗体还不在最前面.我不知道怎么找到它阿(得到它的句柄)
可以的呀