捞面卤的做法:VB程序简单问题求救

来源:百度文库 编辑:高考问答 时间:2024/04/29 05:02:14
如何把user.frm窗体放置在main.frm之上(在main.frm前列)

意思就是说:当两个窗口都打开。user.frm 永远在main.frm之上

两种方案详细解说:
①在main窗体的Load事件中
Private Sub Form_Load()
user.Show 1, Me
End Sub

这时候其实main还没有加载完,所以只有user打开,由于是vbModal模式,main窗体的加载被中断了,只有但关闭user时,main才会打开。从实现效果的意义上讲,是user抢在main前(时间),而非user在main之上(空间层次)

②在main窗体的Resize事件中
Private Sub Form_Resize()
user.Show 1, Me
End Sub

此时main窗体已经加载完毕,因此可以保证两者同时存在,且user在main之上。

main.frm里面:
Private Sub Form_Load()
user.Show vbModal,Me
End Sub

使指定窗口总处于其他窗口之上

将以下代码加入到Form中,这个Form就成为一个在其他所有窗口之上的窗口了.

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

Const HWND_TOPMOST = -1

Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX _
, Me.Top Screen.TwipsPerPixelY, Me.Width Screen.TwipsPerPixelX, _
Me.Height Screen.TwipsPerPixelY, 0
End Sub