Search code examples
vb6

Bold window borders with fixed size


From Windows Vista, although some windows are not resizable, but the borders are bold. Is there a way to make bold window borders(unresizable) in VB6?


Solution

  • Your Form's BorderStyle property dictates if the window will be resizable or not. You can chose between the following:

    0 - None (no border)
    1 - Fixed Single
    2 - Sizable
    3 - Fixed Dialog
    4 - Fixed ToolWindow
    5 - Sizable ToolWindow
    

    As far as the visual appearance of the window in Vista, the resizing behavior shouldn't be affected.

    Edit

    If you want to prevent the form from resizing while keeping the resizable border style, you can override the Height and Width in the Form_Resize event:

    Private Sub Form_Resize()
        Me.Width = m_lngOriginalWidth
        Me.Height = m_lngOriginalHeight
    End Sub
    

    You will need to store the original Height and Width at some point. You can do this in Form_Load or declare constants to store the original values:

    Dim m_lngOriginalWidth As Long
    Dim m_lngOriginalHeight As Long
    
    Private Sub Form_Load()
        m_lngOriginalWidth = Me.Width
        m_lngOriginalHeight = Me.Height
    End Sub