- 积分
- 1912
- 明经币
- 个
- 注册时间
- 2010-5-11
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2014-10-12 23:11:00
|
显示全部楼层
用API试试看
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Dim ThisHwnd As Long
Public sCurrentCaption As String
Private Sub UserForm_Activate()
sCurrentCaption = BatPlot.Caption
Call EnumWindows(AddressOf EnumWindowsProc, vbNull)
Call SubClass
End Sub
Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Integer
Dim title As String * 32
Call GetWindowText(hwnd, ByVal title, 32)
' If InStr(title, "示例窗体") Then '根据窗体的"Caption"值来枚举
If InStr(title, sCurrentCaption) Then
ThisHwnd = hwnd '已找到窗体,则退出
EnumWindowsProc = False
Else
EnumWindowsProc = True '未找到,继续枚举
End If
End Function
Public Function SubClass() As Long
Dim flags As Long
flags = GetWindowLong(ThisHwnd, GWL_STYLE)
flags = flags Xor WS_POPUP
SetWindowLong ThisHwnd, GWL_STYLE, flags
End Function
不知道你的具体情况,你只能试试 |
|