【API函数】怎么得到当前桌面的 置顶窗口
【API函数】如何得到当前桌面的 置顶窗口
在程序中 我需要将某个窗口置顶(非永远置顶)
我已经把过程写好了
sub SetTopWindows(byval hwnd as long )
setWindowPos hwnd,HWND_TOP,0,0,0,0,SWP_NOSIZE,SWP_NOMOVE
end sub
这个过程由一个主过程调用
但是主过程调用遇到一个异步的问题 ,那就是 SetTopWindows 之前的一个过程也有相关的置顶功能 (假设为 sub1() )
sub Main()
dim clsName as string
claName = "notepad"
sub1() ' 这过程一定要是一个异步过程,不能使用waitsingleobject之类的方法解决问题,可能持续的时间为几十秒到 1 分钟,但是只有前几秒有置顶窗口的功能
SetTopWindows(FindWindow(clsName,vbNullString))'A1处
end sub
所以我希望把A1处的代码改成
do while condition1 ' 这里写入一个当前置顶的窗口句柄的判断,
SetTopWindows(FindWindow(clsName,vbNullString))
Sleep(100)
loop
请问用什么API 函数,或者什么方法
------解决方案--------------------
在程序中 我需要将某个窗口置顶(非永远置顶)
我已经把过程写好了
sub SetTopWindows(byval hwnd as long )
setWindowPos hwnd,HWND_TOP,0,0,0,0,SWP_NOSIZE,SWP_NOMOVE
end sub
这个过程由一个主过程调用
但是主过程调用遇到一个异步的问题 ,那就是 SetTopWindows 之前的一个过程也有相关的置顶功能 (假设为 sub1() )
sub Main()
dim clsName as string
claName = "notepad"
sub1() ' 这过程一定要是一个异步过程,不能使用waitsingleobject之类的方法解决问题,可能持续的时间为几十秒到 1 分钟,但是只有前几秒有置顶窗口的功能
SetTopWindows(FindWindow(clsName,vbNullString))'A1处
end sub
所以我希望把A1处的代码改成
do while condition1 ' 这里写入一个当前置顶的窗口句柄的判断,
SetTopWindows(FindWindow(clsName,vbNullString))
Sleep(100)
loop
请问用什么API 函数,或者什么方法
------解决方案--------------------
- VB code
'Example Name:Window Draw Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Sub Form_Activate() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net Dim Ret As Long Do 'Get the handle of the foreground window Ret = GetForegroundWindow() 'Get the foreground window's device context Ret = GetDC(Ret) 'draw an ellipse Ellipse Ret, 0, 0, 200, 200 DoEvents Loop End Sub
------解决方案--------------------
- VB code
Private Declare Function GetForegroundWindow Lib "user32" () As Long