When our app is running in Windowed mode, if a user minimizes and then restores the software it is not resizing properly. It is acting like the screen is Maximized the way it makes everything too large. What is the best way to fix this?
I would like to make sure I am handling everything properly from the first time it loads, to Maximizeing, Minimizeing, Restores... I don't know why this is so hard, but I just can't get it right.
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
I think the one I am having the most issues with is the one Microsoft is taking care of automatically, txtQuestion.width. Any idea why MS would be resizing it wrong?
Here is what I am doing inside my Resize, but like I said before, it looks like the issue is not in here:
vb Code:
Public Sub frmStudy_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize
So you are coding this yourself then. Give it up as a bad job and read this instead . An alternative if you dynamically add controls (which your code suggests it might), then you can use the layout controls.
Note, possibly you are getting an Exception but you have the awful
On Error Resume Next
Line which is hiding it. This has been replaced with TryCatch, I would highly suggest replacing this!
C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter
There's just no reason to use garbage like InputBox. - jmcilhinney
The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber
In addition to removing the On Error Resume Next I would suggest that the entire code be contained within an If Then block which tests the windowstate. You should not be executing any resize code if the windowstate is minimized.
The windows state helped. I removed the On Error, but I am NOT getting any errors. However, when I go from Maximized to Normal, some of the objects are WAY to wide. Any ideas?
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
The tempvars are just for debugging so I could compare the widths. Everything is as expected. Even the Widths that the radio buttons are set to appear correct, they just are way to long when actually displayed on the form.
Originally Posted by DataMiser
Why are you defining all these vars and not using them?
Why is this in the textchanged event?
Code:
Dim tempvar As Size = rbOption4.MaximumSize
Dim tempvar2 As Integer = Me.txtQuestion.Width
Dim tempvar3 As Integer = Me.Width
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
I still do not understand why you would have that in a handler for textchanged. Seems like that would execute far to often best case it will waste cpu cycles worst case cause unexpected behaviour
would def throw an error. Dividing the hieght by two would return a double, and an integer plus a double does not equal an integer. Take a look at grimfort's option strict/explicit link in the signature.
Ok, I turned on Option Explicit and Option Strict. The same thing is happening. If you resize the window it works amazing. But if you Maximize and then go to Normal it does not resize properly. Notice that the scroll bar shows that the control is super wide. But if you look here the sizes seem correct on the tempvars.
It is hard for us to debug something that could depend on so many other things, such as control parents, other event code (why are you changing the MaximumSize?) that could be changing the order.
I mentioned above, but will mention again. Give up on hardcoding this, just anchor the controls, job done.
Each of the 4 controls re-size their height automatically to fit content, I did not think that anchors work with this? Basically the 4 controls are in a panel.
Originally Posted by Grimfort
It is hard for us to debug something that could depend on so many other things, such as control parents, other event code (why are you changing the MaximumSize?) that could be changing the order.
I mentioned above, but will mention again. Give up on hardcoding this, just anchor the controls, job done.
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
You can anchor controls within controls. If you want to collect the answers together, put them into their own panel. A panel has an AutoScroll property, which will auto-add scroll bars when your view is outsize the area. You also have layout controls, one being a table, which can simply be 1 column X 4 rows. All you set is the height.
You can also use splitter panels to allow the user to manually size the area, or, just use it with a fixedpanel (ie the question), and sit the answers within the other side of the splitter. It is just a case of breaking down the screen into sections, yours looks like it has 4 major (2x2 grid, perfect for tablelayout). The answers has more, so maybe another tablelayout inside (put it inside a panel first, makes selection easier).
I have had issues with sizing when dynamically inserting usercontrols within tabbed controls, within usercontrols, within docked forms, within MDI. And then I reverted to a bit of code to fix it. Other than that, everything else is easy do-able by anchoring and docking.