Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long Public Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long Public Const GWL_STYLE = (-16) Public Const WS_MAXIMIZEBOX = &H10000 Public Const WS_MINIMIZEBOX = &H20000 Public Const WS_THICKFRAME = &H40000 Public Const WM_SETICON = &H80 Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex 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 Sub add_menu(FM As Object) Dim hwnd1 As Long Dim IsTyle As Long hwnd1 = FindWindow(vbNullString, FM.Caption) IsTyle = GetWindowLong(hwnd1, GWL_STYLE) IsTyle = IsTyle Or WS_MAXIMIZEBOX Or WS_MINIMIZEBOX Or WS_THICKFRAME SetWindowLong hwnd1, GWL_STYLE, IsTyle End Sub
Private Sub UserForm_Initialize() '定義視窗初始化 Call add_menu(Me) taqw = Me.Width taqh = Me.Height oldw = Me.Width oldh = Me.Height tmp1 = 1 tmp2 = 1 End Sub
Private Sub UserForm_Resize() 'Userform 的大小變更變數 Dim oldw2, oldh2 '將所有物件定義為變數 Dim cbar As Control oldw2 = Me.Width / oldw oldh2 = Me.Height / oldh If (dcut Mod 2) <> 0 Then For Each cbar In Me.Controls With cbar .Width = .Width * oldw2 .Height = .Height * oldh2 .Left = .Left * oldw2 .Top = .Top * oldh2 End With Next cbar Else For Each cbar In Me.Controls With cbar .Width = .Width / tmp1 .Height = .Height / tmp2 .Left = .Left / tmp1 .Top = .Top / tmp2 End With Next cbar End If dcut = dcut + 1 tmp1 = oldw2 tmp2 = oldh2 UserForm1.Repaint End Sub
[此贴子已经被作者于2008-3-5 15:31:23编辑过] |