如题!我用HWND_BOTTOM 不起任何作用!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 Const HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOWS = &H40
Public Sub setPos()
Dim retValue As Long
Dim h As Long, v As Long
Dim left As Long, top As Long h = GetDeviceCaps(Me.hdc, HORZRES) '屏幕宽度
v = GetDeviceCaps(Me.hdc, VHORZRES) '屏幕高度
left = CStr(h) * 0.72 - frmDayInfo.ScaleWidth
top = CStr(v) * 0.64 retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, left, top, Me.ScaleWidth, Me.ScaleHeight, SWP_SHOWWINDOWS)
end sub
Private Const HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOWS = &H40
Public Sub setPos()
Dim retValue As Long
Dim h As Long, v As Long
Dim left As Long, top As Long h = GetDeviceCaps(Me.hdc, HORZRES) '屏幕宽度
v = GetDeviceCaps(Me.hdc, VHORZRES) '屏幕高度
left = CStr(h) * 0.72 - frmDayInfo.ScaleWidth
top = CStr(v) * 0.64 retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, left, top, Me.ScaleWidth, Me.ScaleHeight, SWP_SHOWWINDOWS)
end sub
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_BOTTOM = 1
Const HWND_TOP = 0
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2 Const SWP_FRAMECHANGED = &H20
Const SWP_HIDEWINDOW = &H80
Const SWP_NOACTIVATE = &H10
Const SWP_NOCOPYBITS = &H100
Const SWP_NOMOVE = &H2
Const SWP_NOREDRAW = &H8
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4
Const SWP_SHOWWINDOW = &H40 Enum WindowPos
OnTop = 1
Normal = 2
OnBottom = 3
End Enum Private Sub FormPos(hwnd As Long, Pos As WindowPos)
Select Case Pos
Case WindowPos.OnTop
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Case WindowPos.Normal
SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
Case WindowPos.OnBottom
SetWindowPos hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Select
End SubPrivate Sub Command1_Click()
FormPos Me.hwnd, OnBottom
End Sub
顺便说一下,下面两句有问题:
left = CStr(h) * 0.72 - frmDayInfo.ScaleWidth
top = CStr(v) * 0.64你需要的不是字串,不应该用cstr函数将数字转为字串,应该这样:
left = h * 0.72 - frmDayInfo.ScaleWidth
top = v* 0.64
Private Const HWND_TOPMOST = -1是把你的窗口放在顶部