如何判断窗体是否最前

原来如此 2008-08-05 02:46:35
如何判断窗体是否最前?加入一个if...else...end if语句,如果窗体最前则让他不最前,如果窗体不最前则使他最前?应该如何实现?
...全文
190 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mokton 2008-08-07
  • 打赏
  • 举报
回复
使用三个API函数就可以了GetForegroundWindow() GetWindowTextLength() GetWindowText()

'判断制定窗口是否在最前端
Function header(frmName As String) As Boolean
hWnd1 = GetForegroundWindow() '得到活动窗口的句柄
if getCaption(hWnd1) = frmName then
header = True
else
header = False
End If
End Sub

'根据窗口句柄得到该窗口的标题
Function getCaption(hWnd As Long)
Dim hWndlength As Long, hWndTitle As String, A As Long
hWndlength = GetWindowTextLength(hWnd)
hWndTitle = String$(hWndlength, 0)
A = GetWindowText(hWnd, hWndTitle, (hWndlength + 1))
getCaption = hWndTitle
End Function
原来如此 2008-08-05
  • 打赏
  • 举报
回复
知道的能贴一下代码吗?
迈克揉索芙特 2008-08-05
  • 打赏
  • 举报
回复
GetActiveWindow + ZOrder
weberli 2008-08-05
  • 打赏
  • 举报
回复
用zorder设置
嗷嗷叫的老马 2008-08-05
  • 打赏
  • 举报
回复
.........还不够明白么.

你直接搜索一下那两个东西呢?
原来如此 2008-08-05
  • 打赏
  • 举报
回复
楼上的能说明白点吗

7,763

社区成员

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

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