Resize a .NET form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    Resize a .NET form

    I want to resize the height of a form without resizing the width,
    therefore I tried:

    Private Sub Form1_Resize(By Val sender As Object, ByVal e As System.EventArg s) Handles MyBase.Resize

    Me.Width = 226

    End Sub

    However this causes a lot of flickering on my form. How can I turn
    off the flickering ?

    Please help, RS

  • Armin Zingler

    #2
    Re: Resize a .NET form

    "Rob" <rls_jls@worldn et.att.netschri eb
    I want to resize the height of a form without resizing the width,
    therefore I tried:
    >
    Private Sub Form1_Resize(By Val sender As Object, ByVal e As
    System.EventArg s) Handles MyBase.Resize
    >
    Me.Width = 226
    >
    End Sub
    >
    However this causes a lot of flickering on my form. How can I turn
    off the flickering ?

    Example:

    Imports System.Runtime. InteropServices

    Public Class Form1

    <StructLayout(L ayoutKind.Seque ntial)_
    Private Structure MinMaxInfo
    Public reserved As Point
    Public maxSize As Point
    Public maxPosition As Point
    Public minTrackSize As Point
    Public maxTrackSize As Point
    End Structure

    Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)

    Const WM_GETMINMAXINF O As Integer = &H24

    MyBase.WndProc( m)

    If m.Msg = WM_GETMINMAXINF O Then
    Dim mmi As MinMaxInfo

    mmi = DirectCast( _
    Marshal.PtrToSt ructure(m.LPara m, GetType(MinMaxI nfo)), _
    MinMaxInfo _
    )

    mmi.maxTrackSiz e.X = 226
    mmi.minTrackSiz e.X = 226

    Marshal.Structu reToPtr(mmi, m.LParam, True)
    End If

    End Sub

    End Class




    Armin

    Comment

    • Phill W.

      #3
      Re: Resize a .NET form

      Rob wrote:
      I want to resize the height of a form without resizing the width,
      Private Sub Form1_Resize(By Val sender As Object, ByVal e As
      System.EventArg s) Handles MyBase.Resize
      Me.Width = 226
      End Sub
      However this causes a lot of flickering on my form.
      Fix the width of the form using MinimumSize and MaximumSize:

      Me.MinimumSize = New Size( 226, 0 )
      Me.MaximumSize = New Size( 226, 600 ) ' say

      Better still, get the current screen size and use that for the maximum
      height instead - I can't' remember the code just at the moment.

      HTH,
      Phill W.

      Comment

      • rowe_newsgroups

        #4
        Re: Resize a .NET form

        Better still, get the current screen size and use that for the maximum
        height instead - I can't' remember the code just at the moment.
        I'm guessing you're referring to either
        Screen.PrimaryS creen.Bounds.He ight or
        Screen.PrimaryS creen.WorkingAr ea.Height

        Thanks,

        Seth Rowe

        Comment

        • Phill W.

          #5
          Re: Resize a .NET form

          rowe_newsgroups wrote:
          >Better still, get the current screen size and use that for the maximum
          >height instead - I can't' remember the code just at the moment.
          >
          I'm guessing you're referring to either
          Screen.PrimaryS creen.Bounds.He ight or
          Screen.PrimaryS creen.WorkingAr ea.Height
          That's the ones!

          WorkingArea is the better of the two, taking into account those awkward
          people (like me) who move the Start bar around the screen and make it a
          different size ... ;-)

          Regards,
          Phill W.

          Comment

          Working...