473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Resize a .NET form

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
4 1779
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roger | last post by:
Hi All, I have an app where I change the size of the form at run time using controls and I do not want the user to be able to resize the form, I have removed the min and max buttons. I have tried...
3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
1
by: Diogo Alves - Software Developer | last post by:
Hi there, Since my last questions wasn't very clear, I will do it in a different way. I want to resize my app but while resizing I dont want to see content of the form, I just want to see the...
4
by: Rob Richardson | last post by:
Greetings! I have a form with a listview, a menu, and a few text boxes, labels and command buttons. I want to resize the listview when the form is resized to that the widths of the spaces...
2
by: DraguVaso | last post by:
Hi, I have to DataGrid's on a form, one on the top of my form, the other at the bottom, but they though each other somewhere in the middle. What I want now is that, when I resize the form, they...
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
11
by: Ajith Menon | last post by:
I have created a windows application in which the form needs to be resized on the MouseMove event. The windows resize function takes a lot of CPU cycles. And as the resize function is called on the...
2
by: Smitty | last post by:
Did a search & found nothing on this. VB6 did a resize on form load according to what I've read. I Resized screen under vista & now the text box doesn't resize to form's clientarea. Code exists...
1
by: Bob Alston | last post by:
I have a system where many subforms are used. Often the size of the subform had to be larger than could be displayed without scrolling. I set the height of the subform to the typical height...
10
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.