By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,940 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,940 IT Pros & Developers. It's quick & easy.

Resize a .NET form

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

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) 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

Aug 1 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Rob" <rl*****@worldnet.att.netschrieb
I want to resize the height of a form without resizing the width,
therefore I tried:

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) 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(LayoutKind.Sequential)_
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_GETMINMAXINFO As Integer = &H24

MyBase.WndProc(m)

If m.Msg = WM_GETMINMAXINFO Then
Dim mmi As MinMaxInfo

mmi = DirectCast( _
Marshal.PtrToStructure(m.LParam, GetType(MinMaxInfo)), _
MinMaxInfo _
)

mmi.maxTrackSize.X = 226
mmi.minTrackSize.X = 226

Marshal.StructureToPtr(mmi, m.LParam, True)
End If

End Sub

End Class


Armin
Aug 1 '07 #2

P: n/a
Rob wrote:
I want to resize the height of a form without resizing the width,
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) 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.
Aug 1 '07 #3

P: n/a
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.PrimaryScreen.Bounds.Height or
Screen.PrimaryScreen.WorkingArea.Height

Thanks,

Seth Rowe

Aug 1 '07 #4

P: n/a
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.PrimaryScreen.Bounds.Height or
Screen.PrimaryScreen.WorkingArea.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.
Aug 2 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.