|
-
Feb 16th, 2011, 11:51 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Form resizing
I have the darndest problem. One of my forms resizes itself. In the development environment the size is 605/301. When the program runs it is much larger. In the form_load event I put the me.Width & me.Height commands and it still is much larger. I looked at the "hidden" windows forms code and can't see any resizing going on. I added a msgbox with the width & height. It says 605 & 301, yet the form is much larger.
I have run out of ideas.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 16th, 2011, 12:01 PM
#2
Re: Form resizing
Look at your form's .Designer.vb file. What size is there? Do you use any third-party components?
Does your code tamper with the form's dimensions in any way?
-
Feb 16th, 2011, 12:03 PM
#3
Thread Starter
PowerPoster
Re: Form resizing
I can't see where it is making the form larger. If anything, it is trying to make it smaller. I did put the me.width & me.height statements at the start of the form_load event. That worked on other forms, but not this one.
'
'frmOrderHistory
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 14.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(599, 276)
Me.Controls.Add(Me.fGrid1)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Location = New System.Drawing.Point(16, 107)
Me.MaximizeBox = False
Me.Name = "frmOrderHistory"
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultBounds
Me.Text = "Order History"
CType(Me.fGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 16th, 2011, 12:11 PM
#4
Re: Form resizing
ClientSize IS NOT THE SAME as the window size.
-
Feb 16th, 2011, 12:18 PM
#5
Thread Starter
PowerPoster
Re: Form resizing
True enough. However, there is no mention of window size anywhere. This is an MDI child form. The MDI form is maximized. Using width & height made all of the other forms play nice. This particular form does not want to comply.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 16th, 2011, 01:19 PM
#6
Re: Form resizing
Are the DPI settings different on the development machine and runtime machine? If so, your form might be scaled *or* your concept of how pixels map to physical dimensions is wrong.
-
Feb 16th, 2011, 01:30 PM
#7
Thread Starter
PowerPoster
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 16th, 2011, 01:41 PM
#8
Re: Form resizing
Could you post a screenshot of the desktop with the window on it? That'd help us figure out how much larger it really is. Alternatively, could you post a solution that reproduces the problem?
-
Feb 16th, 2011, 01:52 PM
#9
Thread Starter
PowerPoster
Re: Form resizing
I don't know how to post a picture here. I did take a screen shot of the IDE and a screen shot of the running app to show what I mean. Is there an email address that I can send them to?
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 16th, 2011, 02:36 PM
#10
Re: Form resizing
When you make a post, there's an "Attach files" section beneath the input text (If you use quick reply, you have to click the "Go Advanced" button to get the full posting UI.) It looks like bmp, jpg, and png files are accepted. I'd recommend jpg or png to keep file size less than ridiculous.
Alternatively, it looks like you could use one of the numerous image hosts like yFrog and click the "insert image" button.
-
Feb 16th, 2011, 02:48 PM
#11
Thread Starter
PowerPoster
Re: Form resizing
Let me give it a shot:
Didn't work. I will try again tomorrow.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 17th, 2011, 10:43 AM
#12
Thread Starter
PowerPoster
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 18th, 2011, 10:00 AM
#13
Thread Starter
PowerPoster
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 18th, 2011, 11:43 AM
#14
Re: Form resizing
The first one's useful; the second has been resized so small it's completely useless. I missed that it was an MDI child form; I'm not sure if it's important but I know MDI forms can get wonky sometimes. It looks like the form's about 100px larger in each dimension than it should be; maybe 794x410 when you want 605x301 (assuming you didn't resize the first screenshot, which would make measurement invalid without knowing the original resolution.)
I'm stumped, and I don't think it's possible to do more than make random guesses if we can't see your code. I just played around with a lot of different ways to add forms to an MDI form and didn't encounter any troubles with getting the wrong size.
Have you tried adding a new form to the project to see if it gets the size it needs? If that works properly, I'd imagine the best thing to try is to create a new form and slowly bring over code from the misbehaving form. Build frequently and test it. The moment you get wonky sizing behavior, you know the last thing you moved over is the cause and you can narrow your focus.
-
Feb 18th, 2011, 12:19 PM
#15
Thread Starter
PowerPoster
Re: Form resizing
The 2nd form is just to show how it looks in the IDE. As you can see it looks "normal". The size in the IDE is 605,301. In the form load event I have also put
Code:
Me.Width = 605
Me.Height = 301
I give up.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 18th, 2011, 04:39 PM
#16
Re: Form resizing
This might be completely useless but it's worth a try: try overriding the OnResize method of the form (or the Height/Width or Size properties if possible) and throw an exception there. Then look at the stack trace to see what caused the resize.
maybe something like this
Code:
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Throw New Exception()
End Sub
If I'm not horribly mistaken execution should halt here (on the exception) and you can view the stacktrace in the exception dialog.
-
Feb 25th, 2011, 09:48 AM
#17
Thread Starter
PowerPoster
Re: Form resizing
I will give that a shot. Thanks.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Feb 28th, 2011, 11:52 AM
#18
Thread Starter
PowerPoster
Re: Form resizing
Well, the plot thickens. I installed the app on a user's PC. Almost all of the forms are not being displayed correctly. I tried changing the display settings and it made no difference. So, I thought, maybe it works on my PC because I am using the IDE. So, I installed it on my PC and the screens look fine. I changed my display settings and they still looked fine.
So, the same app is installed on 3 different PCs. On one, all is fine. On another, a couple are not sizing correctly. On the 3rd, almost all are incorrect (I say 'almost' because I did not check every screen).
I am at a loss. They are all running XP Pro SP3.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Mar 2nd, 2011, 10:35 AM
#19
Thread Starter
PowerPoster
Re: Form resizing
I think I found it!!
I changed the Startup Position from WindowsDefaultBounds to centerParent and the sizing is all working now. Not sure why, but being a child form and not centering on parent must have confused it.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|