Hello, I have a single form that starts up in the Normal State and StartPostion set to Manual.
When the user clicks on the Maximize button, I would like to specify the location the form, instead of the upper left corner. Is this possible
Thanks, steve

How to Specify Form Location when Maximized
Mircea Marghidanu
Hi Steve, Thank you very much for your reply.
I have tried your examples and they work as specified.
And you are right. What I want isn't standard windows behaviour.
Here is some more info.
My form properties:
Size 1200,230
MaximumSize 1200,600
The StartPosition and WindowState are set by the Load event.
WindowState = FormWindowState.Normal
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea
' Set the location so the entire form is center/bottom.
Me.Location = New Point((workingRectangle.Width - Me.Size.Width) / 2, _
workingRectangle.Height - Me.Size.Height)
Since my form is short in both modes (normal & maximized), the visual effect
that I want is that the bottom of the form is always "Docked" to the TaskBar and centered horizontally.
If I try to set location by checking if the form is in maximized state(like example below) using a form event.
The StartPosition is correct but when I press Maximize, the form still locates in the upper left corner. Then on Restore the form size returns to normal and now the new location occurs.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea
If (Me.WindowState = FormWindowState.Maximized) Then
' Set the location so the entire form is center/bottom.
Me.Location = New Point(((workingRectangle.Width - Me.Size.Width) / 2), _
(workingRectangle.Height - 600))
End If
Thanks, steve
Christoffee
Hi Steve,
I'm assuming what you mean is "when the form is maximized and the user clicks on the Maximize button", otherwise clicking the Maximize button causes the form to fill the screen. If the form is already maximized, clicking the button restores it to its previous size and location - this is the default Windows behavior. If you haven't explicitly set the startup location, the form will start in the upper left corner, and assuming that the user hasn't moved it it will be restored to that position.
If you want to manually set the location when the application starts, the following code would position the form 300 pixels down and 300 pixels to the right, instead of in the upper left corner:
Private
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Location = New System.Drawing.Point(300, 300) End SubIf you really need to position the form when it is maximized and the user clicks the Maximize button, the following should do the trick (but as I noted, this isn't standard Windows behavior):
Private
Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged Me.Location = New System.Drawing.Point(100, 100) End SubHope this helps,
Steve Hoag
Visual Basic Express
epion
Hi Steve -
So if I understand you correctly, you always want the form docked to the bottom of the screen, but you want to allow the user to change the height - similar to the behavior of the taskbar, but sitting above the taskbar
If so, why don't you just remove the Maximize button altogether (Me.MaximizeBox = False) and then in the SizeChanged event add code that calculates the bottom of your working rectangle and positions the form accordingly
- Steve
PatrickEh
Steve, Good Idea!
I'll give it a try.
Thanks for your help. I really do appreciate it.
Best regards,
Steve N.