如何得知窗口 hWnd 是不是MDI类型窗口

二师兄的老公 2003-10-16 10:10:47
先 hWnd = GetActiveWindow();
再判断 hWnd 是否为MDI类型窗口。
怎么做?
...全文
55 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
kmzs 2003-10-16
  • 打赏
  • 举报
回复
。。。
二师兄的老公 2003-10-16
  • 打赏
  • 举报
回复
可以采用EnumChildWindows函数遍历子窗口的方法。
不过前提必须是至少有一个子窗口开着!
问题解决!给分!
TechnoFantasy 2003-10-16
  • 打赏
  • 举报
回复
我想可能需要用EnumChildWindows函数遍历窗口的子窗口,看里面是否有Windows窗口类型的子窗口
TechnoFantasy 2003-10-16
  • 打赏
  • 举报
回复
MDI主窗口的风格跟普通的窗口是一致的,假设Form1是普通窗口,MDIForm1是MDI父窗口,你可以用下面的代码:

Dim l As Long

l = GetWindowLong(Form1.hwnd, GWL_STYLE)
Debug.Print Hex(l)
l = GetWindowLong(MDIForm1.hwnd, GWL_STYLE)
Debug.Print Hex(l)


l = GetWindowLong(Form1.hwnd, GWL_EXSTYLE)
Debug.Print Hex(l)
l = GetWindowLong(MDIForm1.hwnd, GWL_EXSTYLE)
Debug.Print Hex(l)

可以看到返回的风格是一样的。
二师兄的老公 2003-10-16
  • 打赏
  • 举报
回复
可能是我问题没说清楚。
TechnoFantasy(www.applevb.com) 的方法是检查窗口是否为MDI子窗口。
我要检查的是:窗口是否为MDI主窗口!
TechnoFantasy 2003-10-16
  • 打赏
  • 举报
回复
Option Explicit

Const WS_EX_MDICHILD = &H40
Const GWL_EXSTYLE = (-20)

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long


Function IsWindowMid(hwnd As Long) As Boolean
Dim x As Long

x = GetWindowLong(hwnd, GWL_EXSTYLE)
If (x And WS_EX_MDICHILD) Then
IsWindowMid = True
Else
IsWindowMid = False
End If
End Function
rainstormmaster 2003-10-16
  • 打赏
  • 举报
回复
笔误,应为getwindowlong
rainstormmaster 2003-10-16
  • 打赏
  • 举报
回复
或者用setwindowlong试试
rainstormmaster 2003-10-16
  • 打赏
  • 举报
回复
试试:
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long


if GetParent(hwnd)=0 then
'no
else
'yes
end if

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧