Jumat, 05 Februari 2016

Minimize UserForm VBA Excel..

Minimize UserForm VBA Excel -
Saya Tidak Punya kelebihan untuk Membahas Arti dari setiap Kode,,Saya Belajar Visual Basic Secara Otoditak..
Langsung Ke TKP....
Langkah-langkah membuat Tombol Minimize UserForm VBA Excel :
  • Buka Visual Basic Dengan Menekan tombol Alt f11
  • Insert Modul, masukkan kode berikut dalam modul tersebut.
Public Const WS_MINIMIZEBOX = &H10000
Public Const WS_MAXIMIZEBOX = &H20000
Public Const GWL_STYLE = (-16)
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
Public Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Public Sub AddMinMaxButtons(ByVal FormCaption As String, ByVal MinButton As Boolean, ByVal MaxButton As Boolean)
Dim hWnd As Long
Dim lngStyle As Long
hWnd = FindWindow(vbNullString, FormCaption)
lngStyle = GetWindowLong(hWnd, GWL_STYLE)
If MaxButton Then
    lngStyle = lngStyle Or WS_MAXIMIZEBOX
End If
If MinButton Then
    lngStyle = lngStyle Or WS_MINIMIZEBOX
End If
SetWindowLong hWnd, GWL_STYLE, lngStyle
DrawMenuBar hWnd
End Sub
  • Langkah selanjutnya masukkan kode berikut di userform
Private Sub UserForm_Activate()
AddMinMaxButtons Me.Caption, MinButton:=False, MaxButton:=True
End Sub

0 komentar:

Posting Komentar

 
Design by Dabloeng.com/