先调用API函数实现窗体总在最上,代码如下: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 LongConst HWND_TOPMOST = -1Private Sub Form_Load()
'总在最上
SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX _
, Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, _
Me.Height \ Screen.TwipsPerPixelY, 0End Sub然后在显示这个窗体时用模态,例如:假设上面的窗体为Form1Form1.Show vbModal这样窗体不仅会在最上,而且必须输入正确的密码才能访问别的窗体
|