五笔打字通主页
VB窗体置顶,这个功能当然还是要靠万能的API来帮忙,先在窗体模块输入以下代码:
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -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 Sub Command1_Click()
SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '设置窗口置顶
End Sub
Private Sub Command2_Click()
SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '取消窗口置顶
End Sub
来源:济亨网
本文链接:http://wb86.com/post/24.html