Meu form tem uma imagem e um status bar. Quando tento redimensionar o form (aumentando ou diminuindo o tamanho) o status bar não acompanha.
Modulo:
Código: Selecionar todos
Option Explicit
Declare PtrSafe Function FindWindowA& Lib "User32" (ByVal lpClassName$, ByVal lpWindowName$)
Declare PtrSafe Function GetWindowLongA& Lib "User32" (ByVal hWnd&, ByVal nIndex&)
Declare PtrSafe Function SetWindowLongA& Lib "User32" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
' Déclaration des constantes
Public Const GWL_STYLE As Long = -16
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_FULLSIZING = &H70000
'Attention, envoyer après changement du caption de l'UF
Public Sub InitMaxMin(mCaption As String, Optional Max As Boolean = True, Optional Min As Boolean = True _
, Optional Sizing As Boolean = True)
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, mCaption)
If Max Then SetWindowLongA hWnd, GWL_STYLE, GetWindowLongA(hWnd, GWL_STYLE) Or WS_MAXIMIZEBOX
If Min Then SetWindowLongA hWnd, GWL_STYLE, GetWindowLongA(hWnd, GWL_STYLE) Or WS_MINIMIZEBOX
If Sizing Then SetWindowLongA hWnd, GWL_STYLE, GetWindowLongA(hWnd, GWL_STYLE) Or WS_FULLSIZING
End Sub
Código: Selecionar todos
Option Explicit
Dim Lg As Single
Dim Ht As Single
Dim Fini As Boolean
Private Sub UserForm_Initialize()
InitMaxMin Me.Caption
Ht = Me.Height
Lg = Me.Width
stmostra.Panels(1).Text = "Desenvolvido por Carlos Alberto Leonel & Shirley Jorge | Diretoria Tecnologia e Sistemas| AeC"
stmostra.Panels(1).AutoSize = sbrSpring
stmostra.Panels(1).Bevel = sbrRaised
txtlogado.Text = USUARIO
End Sub
Private Sub UserForm_Resize()
Dim RtL As Single, RtH As Single
If Me.Width < 300 Or Me.Height < 200 Or Fini Then Exit Sub
RtL = Me.Width / Lg
RtH = Me.Height / Ht
Me.Zoom = IIf(RtL < RtH, RtL, RtH) * 100
End Sub
Private Sub UserForm_Terminate()
Fini = True
End Sub