Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a resizable PictureBox
DescriptionThis example shows how to make a resizable PictureBox in Visual Basic 6. It sets the PictureBox's WS_THICKFRAME style. The rest is automatic.
Keywordsresizable PictureBox, PictureBox
CategoriesControls, API
 
The form's Load event handler uses the SetWindowLong API function to set the PictureBoxes' WS_THICKFRAME style. That automatically lets the user resize the PictureBoxes. When the user resizes a PictureBox, its Resize event handler fires.
 
Private Sub Form_Load()
Dim window_style As Long

    window_style = GetWindowLong(Picture1.hwnd, GWL_STYLE)
    window_style = window_style Or WS_THICKFRAME
    SetWindowLong Picture1.hwnd, GWL_STYLE, window_style
    SetWindowPos Picture1.hwnd, hwnd, 0, 0, 0, 0, _
        SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or _
            SWP_DRAWFRAME

    window_style = GetWindowLong(Picture2.hwnd, GWL_STYLE)
    window_style = window_style Or WS_THICKFRAME
    SetWindowLong Picture2.hwnd, GWL_STYLE, window_style
    SetWindowPos Picture2.hwnd, hwnd, 0, 0, 0, 0, _
        SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or _
            SWP_DRAWFRAME
End Sub
 
This program draws two PictureBoxes, one with a border and one without. The one with a border looks like it has a double border after the program gives it the WS_THICKFRAME style.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated