这个是你需要的吗?Private Const HWND_TOPMOST = -1 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 LongPrivate Sub Command1_Click() Dim x As New Form2 x.Show End SubPrivate Sub Form_Load() Dim lStyle As Long, b As Long With Me SetWindowPos .hwnd, HWND_TOPMOST, (Screen.Width - .Width) / 2 / Screen.TwipsPerPixelX, (Screen.Height - .Height) / 2 / Screen.TwipsPerPixelY, .Width / Screen.TwipsPerPixelX, .Height / Screen.TwipsPerPixelY, 0 End With End Sub
模式化显示要置顶的Form即可。
就是稍微有点闪烁'在每个窗体都添加这个 Private Sub Form_Activate() showForm1 End Sub '公共模块里么的 Sub showForm1() Dim x As Form For Each x In Forms x.ZOrder 1 Next Form1.ZOrder 0 End Sub
前边的窗口不关闭,后面的永远也出不来
form2.show 1
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 LongPrivate Sub Command1_Click()
Dim x As New Form2
x.Show
End SubPrivate Sub Form_Load()
Dim lStyle As Long, b As Long
With Me
SetWindowPos .hwnd, HWND_TOPMOST, (Screen.Width - .Width) / 2 / Screen.TwipsPerPixelX, (Screen.Height - .Height) / 2 / Screen.TwipsPerPixelY, .Width / Screen.TwipsPerPixelX, .Height / Screen.TwipsPerPixelY, 0
End With
End Sub
Private Sub Form_Activate()
showForm1
End Sub
'公共模块里么的
Sub showForm1()
Dim x As Form
For Each x In Forms
x.ZOrder 1
Next
Form1.ZOrder 0
End Sub