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
不知道你的具体情况,你只能试试 在窗口加载时重新设置一下窗口的父窗口为CAD主窗口就行了用setparent 窗口的Initialze事件里加上一句
SetParent FindWindow(vbNullString, Me.Caption),Application.hwnd
这两个API函数你自己声明一下就行了 wwswwswws 发表于 2014-10-12 23:11 static/image/common/back.gif
用API试试看
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ...
谢谢! API 还不太会,目前是学习中,多谢 wuyunpeng888 发表于 2014-10-15 15:21 static/image/common/back.gif
窗口的Initialze事件里加上一句
SetParent FindWindow(vbNullString, Me.Caption),Application.hwnd
这两 ...
我试试,谢谢您的指教, wuyunpeng888 发表于 2014-10-15 15:21
窗口的Initialze事件里加上一句
SetParent FindWindow(vbNullString, Me.Caption),Application.hwnd
这两 ...
正解,多谢大神。 其实这个并不是正解,最正确的是用API函数把弹出窗口的属性去掉
flags = GetWindowLong(FindWindow(vbNullString, Me.Caption), GWL_STYLE)
flags = flags Xor WS_POPUP
SetWindowLong FindWindow(vbNullString, Me.Caption), GWL_STYLE, flags
页:
1
[2]