Private Sub UserControl_Resize()
'Position the constituent controls
Dim BaseHeight As Long
Dim bReDo As Boolean
PicCombo.ScaleMode = vbTwips
UserControl.ScaleMode = vbTwips
BaseHeight = PicCombo.TextHeight("P")
If PicCombo.Appearance = 0 Or PicCombo.BorderStyle = 0 Then
If PicCombo.Height <> BaseHeight + PicCombo.ScaleY(6, vbPixels, vbTwips) Then
PicCombo.Height = BaseHeight + PicCombo.ScaleY(6, vbPixels, vbTwips)
End If
Else
If PicCombo.Height <> BaseHeight + PicCombo.ScaleY(8, vbPixels, vbTwips) Then
PicCombo.Height = BaseHeight + PicCombo.ScaleY(8, vbPixels, vbTwips)
End If
End If
' If Height <> PicCombo.Height Then
' bReDo = True
' End If
Height = PicCombo.Height
PicCombo.Width = UserControl.Width
If UserControl.Width <> 0 Then
picSelection.Move 3, 3, PicCombo.Width - 300, PicCombo.Height - 60
End If
picPopup.Width = UserControl.Extender.Width
DrawComboBtn PicCombo, False, True, True, True
' If bReDo Then
' UserControl_Resize
' End If
End Sub
主要是用到以下API函数:
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_TOOLWINDOW = &H80