473,698 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form.ClientSize bug

Can anyone explain why when i set the .ClientSize of a form, and then check
the .ClientSize when the resize event fires, it is slightly off, generally
20(varys) pixels in the height but not always. I have tried many things to
try to get the clientsize to set properly such as setting autoscale to false
among other things, but the client size will just not set properly. If I
check the client size immediatly after i set it it is correct but by the
time the resize event fires it is off.
Nov 21 '05 #1
3 3089

"Xwire" <rp*****@hotmai l.com> wrote
Can anyone explain why when i set the .ClientSize of a form, and then check
the .ClientSize when the resize event fires, it is slightly off, generally
20(varys) pixels in the height but not always. I have tried many things to
try to get the clientsize to set properly such as setting autoscale to false
among other things, but the client size will just not set properly. If I
check the client size immediatly after i set it it is correct but by the
time the resize event fires it is off.


Anytime you attempt to report abnormal behaviour, be prepared to post
a _small_ demo that will show the error. It will be far easier for anyone to
see what you've used that may have caused the problem, and fix that code
than trying to guess what might be the source of the problem...

LFS
Nov 21 '05 #2
**SIGH** I had a main menu with no menu items, so it was not visible, but
the client size was still taking this into account and increasing the
..ClientSize I set to accomidate the menu.
Nov 21 '05 #3
Man, I got the same bug. I was opening a form and setting the borderstyle
to none in the constructor. Then I set the form's size. Wouldn't you know
it, somehow the 19 pixels get added to the height of the form
(coincidentally , the height of the title bar in XP). Example I set the
form's height to be 300 from a config file in the constructor, after it
finishes loading it is 319!!!!!. Now mind you, there is no title bar
because the border style is none(set in the constructor also).

Ok so you think it has something to do with the title bar don't you. Nah,
it is the menu. The form has a menu on it, and if you use the
SystemInformati on.MenuHeight property you will see it is also 19 pixels.
When I removed the menu from the form, it calculates the height correctly. I
spent about 12 hours trying to figure this crap out. BIG BUG BIG BUG.

Just so you don't say I did not post a demo. I created a simple form and
added one menu item to it, I launched the form from a button on another form.
Here's the relevant functions. Try it first with the menu item. Then
Remove the menu item, and you will see that it screws up the size.

#Region " Windows Form Designer generated code "
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents MenuItem1 As System.Windows. Forms.MenuItem
Friend WithEvents MainMenu1 As System.Windows. Forms.MainMenu
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.MenuItem1 = New System.Windows. Forms.MenuItem
Me.MainMenu1 = New System.Windows. Forms.MainMenu
'
'MenuItem1
'
Me.MenuItem1.In dex = 0
Me.MenuItem1.Te xt = "file"
'
'MainMenu1
'
Me.MainMenu1.Me nuItems.AddRang e(New System.Windows. Forms.MenuItem( )
{Me.MenuItem1})
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(292, 273)
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.StartPositio n = System.Windows. Forms.FormStart Position.Manual
Me.Text = "Form1"

End Sub

#End Region

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()
Me.SuspendLayou t()
'Add any initialization after the InitializeCompo nent() call
SetupForm()
Me.ResumeLayout ()
End Sub
Private Sub SetupForm()
Me.MinimizeBox = False
Me.MaximizeBox = False 'Me.MaximizeBox
Me.Text = ""
Me.FormBorderSt yle = FormBorderStyle .None

Me.Top = 20
Me.Left = 300
Me.Width = 200
Me.Height = 200

Me.ShowInTaskba r = False
End Sub

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Debug.WriteLine (Me.Height)
End Sub
"Xwire" wrote:
Can anyone explain why when i set the .ClientSize of a form, and then check
the .ClientSize when the resize event fires, it is slightly off, generally
20(varys) pixels in the height but not always. I have tried many things to
try to get the clientsize to set properly such as setting autoscale to false
among other things, but the client size will just not set properly. If I
check the client size immediatly after i set it it is correct but by the
time the resize event fires it is off.

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14154
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. Thanks in advance, Chris
2
325
by: Paul Mars | last post by:
How can I get the useable dimensions or coordinates of the working area of a form? All that I can find return the monitor screen area, but I need the usable area inside the open form. Not incl. menu, toolbar, status bar. Dim x As Integer = MdiParent.Height Me.SetDesktopBounds(0, 0, 0, 0)
8
9266
by: Matt | last post by:
I've been searching around for a simple way to display a background image in my MDI form's client area. I want to be able to load the image from file on start up and have it resize as the MDI form is resized. It's the resizing part that I am having trouble with. I've seen a few old posts that point in the right direction but nothing simple. I wondered if they has been any new ideas I have missed.
4
3156
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps further away, completely leaving the selector box area. Any ideas? VS 2003 and VB.Net This is a simple application at the moment but the form is inherited from a
7
3382
by: Terry | last post by:
I have a Mainform with a Statusbar. When opening another form or doing some processing I want to display info in the Statusbar of the Mainform. I have read a lot of articles on this & have come up with the code below. It seems to work(!!!) in that when coding the second form I can see the DisplayStatusMsg of the main form. During debug the code runs through & seemingly executes the call without error. But!...The message is not displayed....
0
1850
by: Patrick Lioi | last post by:
We have form that is used as the base class of all of our forms, let's call it BaseApplicationForm. We have another form, say ChildApplicationForm that inherits from BaseApplicationForm. The child form implements an event handler for the Resize event. Inside BaseApplicationForm.InitializeComponent, this.ClientSize is set to a value. On most of our developers' machines, this.ClientSize = ....; does NOT fire the Resize event, which makes...
14
3418
by: Galen Somerville | last post by:
My current screen resolution is set to 1024 x 768. My form size always comes up as 1032 x 748. I have tried the help sample ' Retrieve the working rectangle from the Screen class ' using the PrimaryScreen and the WorkingArea properties. Dim workingRectangle As System.Drawing.Rectangle = _ Screen.PrimaryScreen.WorkingArea ' Set the size of the form slightly less than size of
6
1949
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I want to implement the following: If the user clicks on the border of a form, then I want to show a box around the form that represents the form's bounds. As the user moves the mouse only the box's bounds would change. When the user releases the mouse the form's bounds would be set to the bounds of the box. Note that this is very similar to how the Splitter control works. Does anybody know how to do this?
3
2560
by: Tsahi Asher | last post by:
hi, i was trying to save the window size of my app using the generated Settings class of Visual C# 2005 Express. for some reason, the stored size was bigger from the actual size, so each time i start the app, it's bigger than before, until it fills the screen (1024*768). the odd thing is, that it works just fine in the IDE, and if i install it on a different computer, and even if i use the executable produced by the IDE instead of the one...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.