
vb如何使一个置顶的窗体在点击任务栏的“显示桌面”按钮后仍然不会被隐藏? 10
展开全部
我曾经做过。不过要窗体的BorderStyle属性为0时才有用的。
点击任务栏的“显示桌面”按钮后所有窗体的windowstate属性=1([最小化],其实Top也是大于screen.height的)。这时只要再次将目标窗体置顶,它就会雄风不倒,依然屹立在屏幕上。。
由此,可以用Timer不间断判断windowstate,当其值为1时,置顶..
下面是代码,注意窗体BorderStyle=0,并添加一个Timer控件,Interval属性设10
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_Load()
SetWindowPos Form1.hwnd, -1, 0, 0, 0, 0, &H1 Or &H2 '置顶
End Sub
Private Sub Timer1_Timer()
If Form1.WindowState = 1 Then SetWindowPos Form1.hwnd, -1, 0, 0, 0, 0, &H1 Or &H2 '再次置顶,坚决不下去
End Sub
自己想到的哦。
点击任务栏的“显示桌面”按钮后所有窗体的windowstate属性=1([最小化],其实Top也是大于screen.height的)。这时只要再次将目标窗体置顶,它就会雄风不倒,依然屹立在屏幕上。。
由此,可以用Timer不间断判断windowstate,当其值为1时,置顶..
下面是代码,注意窗体BorderStyle=0,并添加一个Timer控件,Interval属性设10
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_Load()
SetWindowPos Form1.hwnd, -1, 0, 0, 0, 0, &H1 Or &H2 '置顶
End Sub
Private Sub Timer1_Timer()
If Form1.WindowState = 1 Then SetWindowPos Form1.hwnd, -1, 0, 0, 0, 0, &H1 Or &H2 '再次置顶,坚决不下去
End Sub
自己想到的哦。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询