# 提供你一个API范例(直接拷贝就可以用了),我常会用到,可是....

Posted by 小Sam on December 16, 1998 at 08:36:06:

In Reply to: 请问如何设计的视窗永远显示在最上面.... posted by amy on December 15, 1998 at 12:44:16:

提供你一个API范例,我常会用到,可是好像我用太多了 ,有时要关闭前会出现
'在表单以强制显示时无法再回应....' 详细讯息我忘了,不过并不会影响程式运作,
顺便有谁知道原因可以告知小弟一下....

Private Declare Sub SetWindowPos Lib "User32" _
(ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, _
ByVal X As Integer, ByVal Y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, _
ByVal wFlags As Integer)
Const HWND_TOPMOST = -1
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2

Sub BringToTop(hWndForm As Integer)
Dim nFlags As Integer
nFlags = SWP_NOMOVE Or SWP_NOSIZE
Call SetWindowPos(hWndForm, HWND_TOPMOST, 0, 0, 0, 0, nFlags)
End Sub
-------------------------在Form_Load呼叫就可以了!
Private Sub Form_Load()
BringToTop (Me.hWnd)
End Sub

Follow Ups: