Facebook Twitter Gplus Flickr Pinterest LinkedIn YouTube RSS
Home Excel vba Botón de minimizar y maximizar en Form de vba
formats

Botón de minimizar y maximizar en Form de vba

En base a una pregunta del blog, encontré el siguiente código (el cual no es mi autoría) para poder poner tanto un botón de minimizar y uno de maximizar en un formulario de vba.

El código va en el formulario. Lo comparto:

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) 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 GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const GWL_STYLE As Long = (-16)

Private Sub UserForm_Initialize()
    Dim lngMyHandle As Long, lngCurrentStyle As Long, lngNewStyle As Long
    If Application.Version < 9 Then
        lngMyHandle = FindWindow("THUNDERXFRAME", Me.Caption)
    Else
        lngMyHandle = FindWindow("THUNDERDFRAME", Me.Caption)
    End If
    lngCurrentStyle = GetWindowLong(lngMyHandle, GWL_STYLE)
    lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
    SetWindowLong lngMyHandle, GWL_STYLE, lngNewStyle
End Sub

:: Descargar el ejemplo

 
Tags: ,
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
4 Comments  comments 
  • Jose

    Sergio! muchas gracias por el aporte!

  • Papasmarrone

    Pues felicita de mi parte al autor y gracias por el aporte.

  • http://www.tag-village.info pedro

    Es muy interesante, me gusta lo que publicaste creo que lo recomendare, es lo que andaba buscando

    • http://about.me/sergioacamposh sergioacamposh

      Se te agradecen los comentarios.

Sistema Wordpress corriendo bajo... Windows Server 2008 R2
Follow

Get every new post delivered to your Inbox

Join other followers