Ana Sayfa Userform Userform Minimize / Maximize Yapmak... Userform Minimize / Maximize Yapmak... By -NK Blogger Cuma, Nisan 21, 2017 0 Merhaba, Aşağıdaki kodlarımızı ilgili Userform un kod bölümüne yapıştırıyoruz. Formumuz aşağıdaki görünüme kavuşuyor. Hepsi bu kadar :) Option Explicit Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long 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 Declare Function GetActiveWindow Lib "user32.dll" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Const RGN_DIFF = 4 Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Private Const GWL_STYLE As Long = -16 Private Const GWL_EXSTYLE As Long = -20 Private Const WS_CAPTION As Long = &HC00000 Private Const WS_MINIMIZEBOX As Long = &H20000 Private Const WS_MAXIMIZEBOX As Long = &H10000 Private Const WS_POPUP As Long = &H80000000 Private Const WS_VISIBLE As Long = &H10000000 Private Const WS_EX_DLGMODALFRAME As Long = &H1 Private Const WS_EX_APPWINDOW As Long = &H40000 Private Const SW_SHOW As Long = 5 Dim X1 As Long, Y1 As Long, CX As Double, CY As Double Dim MyCtrl As Control, hWndForm As Long, X As Long Private Sub CommandButton1_Click() Application.Visible = True Unload Me End Sub Private Sub UserForm_Activate() Dim lngCurrentStyle As Long, lngNewStyle As Long lngCurrentStyle = GetWindowLong(hWndForm, GWL_STYLE) lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX lngNewStyle = lngNewStyle And Not WS_VISIBLE And Not WS_POPUP SetWindowLong hWndForm, GWL_STYLE, lngNewStyle lngCurrentStyle = GetWindowLong(hWndForm, GWL_EXSTYLE) lngNewStyle = lngCurrentStyle Or WS_EX_APPWINDOW SetWindowLong hWndForm, GWL_EXSTYLE, lngNewStyle ShowWindow hWndForm, SW_SHOW End Sub Private Sub UserForm_Initialize() X1 = Width Y1 = Height X = 1 'ikon If Val(Application.Version) < 9 Then hWndForm = FindWindow("ThunderXFrame", Caption) 'XL97 Else hWndForm = FindWindow("ThunderDFrame", Caption) 'XL2000, XP, 2003? End If SetWindowLong hWndForm, -16, &H20000 Or &H10000 Or &H84C80080 End Sub Private Sub UserForm_Resize() CX = X1 / Width CY = Y1 / Height For Each MyCtrl In Me.Controls MyCtrl.Top = MyCtrl.Top / CY MyCtrl.Left = MyCtrl.Left / CX MyCtrl.Width = MyCtrl.Width / CX MyCtrl.Height = MyCtrl.Height / CY On Error Resume Next MyCtrl.Font.Size = MyCtrl.Font.Size / CX On Error GoTo 0 Next MyCtrl X1 = Width Y1 = Height End Sub Private Sub minimize_Click() ShowWindow hWndForm, 2 End Sub Tags: arşivbilişimeğitimexcelUserform Facebook Twitter Whatsapp Daha yeni Daha eski