控制窗体的位置而已,试一下下面的代码,一个工程,两个窗体,form1上放一个按钮Option Explicit Private CurentHeight As IntegerPrivate Sub Command1_Click() CurentHeight = 0 Do While CurentHeight < Form2.Height CurentHeight = CurentHeight + (Form1.Height - CurentHeight) / 20 + 1 Form2.Top = CurentHeight - Form2.Height DoEvents Loop End SubPrivate Sub Form_Load() Form2.Top = -Form2.Height Form2.Left = 0 Form2.Show End Sub
细节还没改完 效果有了 Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 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 mbOnTop As Boolean Private Property Let OnTop(Setting As Boolean) If Setting Then SetWindowPos hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Else SetWindowPos hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE End If mbOnTop = Setting End Property Private Sub Command1_Click() Dim lngHandle As Long Dim rctW As RECT Dim lngResult As Long Dim i As Integer OnTop = True lngHandle = FindWindow("Shell_TrayWnd", vbNullString) lngResult = GetWindowRect(lngHandle, rctW) If lngResult > 0 Then
Private CurentHeight As IntegerPrivate Sub Command1_Click()
CurentHeight = 0
Do While CurentHeight < Form2.Height
CurentHeight = CurentHeight + (Form1.Height - CurentHeight) / 20 + 1
Form2.Top = CurentHeight - Form2.Height
DoEvents
Loop
End SubPrivate Sub Form_Load()
Form2.Top = -Form2.Height
Form2.Left = 0
Form2.Show
End Sub
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
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 mbOnTop As Boolean
Private Property Let OnTop(Setting As Boolean)
If Setting Then
SetWindowPos hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Else
SetWindowPos hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End If
mbOnTop = Setting
End Property
Private Sub Command1_Click()
Dim lngHandle As Long
Dim rctW As RECT
Dim lngResult As Long
Dim i As Integer
OnTop = True
lngHandle = FindWindow("Shell_TrayWnd", vbNullString)
lngResult = GetWindowRect(lngHandle, rctW)
If lngResult > 0 Then
Me.Top = VB.Screen.Height - (rctW.Bottom - rctW.Top)
Me.Left = VB.Screen.Width - Me.Width
For i = 0 To Me.Height + (rctW.Bottom - rctW.Top)
Me.Move Me.Left, Me.Top - 1, Me.Width, Me.Height
DoEvents
Next
End If
End Sub