none
Maximizar Formulário RRS feed

  • Pergunta

  • Pessoal, boa tarde.

    Tenho o seguinte código que insere os botões Maximizar e Minimizar.

    Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd 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 GetWindowLong Lib "user32" Alias "GetWindowLongA" _
           (ByVal hWnd As Long, ByVal nIndex 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 GetSystemMenu Lib "user32" _
           (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function DeleteMenu Lib "user32" _
           (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) _
            As Long
    
    Private Const GWL_STYLE As Long = (-16)
    Private Const WS_SYSMENU As Long = &H80000
    Private Const WS_MINIMIZEBOX As Long = &H20000
    Private Const WS_MAXIMIZEBOX As Long = &H10000
    Private Const SC_CLOSE As Long = &HF060


    Dim lngFrmHndl As Long, lngStyle As Long
      lngFrmHndl = FindWindow(vbNullString, Me.Caption)
      lngStyle = GetWindowLong(lngFrmHndl, GWL_STYLE)
      lngStyle = lngStyle Or WS_SYSMENU Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
      SetWindowLong lngFrmHndl, GWL_STYLE, lngStyle
      DrawMenuBar lngFrmHndl

    Necessito que, quando maximizar o formulário os objetos se mantenham no centro do formulário.

    Caso alguém possa ajudar, agradeceria muito.

    terça-feira, 21 de julho de 2015 16:44

Respostas

  • Matheus, utilize o evento RESIZE, que ocorre ao maximizar ou minimizar o formulário.

    A partir do acionamento desse evento você pode manipular as propriedades do controle (altura, largura, posição, etc)

    Veja o exemplo abaixo:

    https://msdn.microsoft.com/pt-br/library/office/gg264809.aspx?f=255&MSPPError=-2147217396

    • Sugerido como Resposta André Santo terça-feira, 21 de julho de 2015 20:15
    • Marcado como Resposta matmendes segunda-feira, 27 de julho de 2015 18:25
    terça-feira, 21 de julho de 2015 20:15