用VB制作软件,如何让窗体始终保持在屏幕最前端?
我用VB制作了一个小软件,现要求让它始终保持在屏幕最前端显示。有尝试过使用下列代码:但是效果不好,因为这样会影响其它程序窗口的显示。问有什么好的办法?...
我用VB制作了一个小软件,现要求让它始终保持在屏幕最前端显示。有尝试过使用下列代码:但是效果不好,因为这样会影响其它程序窗口的显示。问有什么好的办法?
展开
2个回答
展开全部
朋友这个代码可以解决你的问题,谢谢!
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 Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Sub Timer1_Timer()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
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 Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_TOPMOST = -1
Private Sub Timer1_Timer()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function SetWindowPos Lib "user32.dll" (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 Boolean
Private Sub Form_Load()
SetWindowPos Me.hwnd, -1, Me.Left, Me.Top, Me.Width, Me.Height, &H2 Or &H1
End Sub
Private Sub Form_Load()
SetWindowPos Me.hwnd, -1, Me.Left, Me.Top, Me.Width, Me.Height, &H2 Or &H1
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询