tim8w
asked on
Adjusting Form's Size
I have a PictureBox that gets loaded dynamically. Sometimes this ends up making the picture get trimmed. I'd like to adjust the form based on the size of this picture. How do I do this? I'm a little confused as to what values I should use .width, .scalewidth, etc.
Thanks,
Tim
Thanks,
Tim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub Command1_Click()
Dim TitleInfo As TITLEBARINFO
TitleInfo.cbSize = Len(TitleInfo)
GetTitleBarInfo Me.hwnd, TitleInfo
Debug.Print "Title bar rectangle:"
With TitleInfo.rcTitleBar
MsgBox .Bottom - .Top
End With
End Sub
Option Explicit
Private Const CCHILDREN_TITLEBAR = 5
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type TITLEBARINFO
cbSize As Long
rcTitleBar As RECT
rgstate(CCHILDREN_TITLEBAR ) As Long
End Type
Private Declare Function GetTitleBarInfo Lib "user32.dll" (ByVal hwnd As Long, ByRef pti As TITLEBARINFO) As Long
That will message box the titlebar height. However, I think it should remain the same (19). Yet, maybe
not.
Dim TitleInfo As TITLEBARINFO
TitleInfo.cbSize = Len(TitleInfo)
GetTitleBarInfo Me.hwnd, TitleInfo
Debug.Print "Title bar rectangle:"
With TitleInfo.rcTitleBar
MsgBox .Bottom - .Top
End With
End Sub
Option Explicit
Private Const CCHILDREN_TITLEBAR = 5
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type TITLEBARINFO
cbSize As Long
rcTitleBar As RECT
rgstate(CCHILDREN_TITLEBAR
End Type
Private Declare Function GetTitleBarInfo Lib "user32.dll" (ByVal hwnd As Long, ByRef pti As TITLEBARINFO) As Long
That will message box the titlebar height. However, I think it should remain the same (19). Yet, maybe
not.
ASKER
Thanks. That worked great. Is there anyway to know what the height of the title bar is?
Thanks,
Tim