Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible the mdi parent form to be unmovable at runtime?

Status
Not open for further replies.

assimang

Programmer
Mar 11, 2008
96
Hello everybody.
I am new in vb 2005. I have a mdi application. Is it possible the mdi parent form to be unmovable at runtime? And how can i do this? It's my central form in my application so i don't want set the formborderstyle to none. Any help will be much appreciated.

Thanks in advanced.
 
If you want the form to always be maximized, this will do it:

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
Me.WindowState = FormWindowState.Maximized
End Sub

This will make the form maximized if the user clicks the minimize button, clicks the maximize button or clicks (single or double) on the taskbar icon. You will see the form change to the requested size, but it then goes right back to maximized.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
thanks sorwen i am getting error 'type system.drawing.location' is not defined in this statement:
Me.Location = New System.Drawing.Location(0,0) although i have declared "Imports System.Drawing
 
Code:
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
    Me.WindowState = FormWindowState.Maximized
End Sub

jebenson, I've already suggested that (see my post: 11 Mar 08 13:33)

======================================

However try the following:

In the designer:

Make sure that the MaximizeBox is set to True
and the MinimizeBox is set to False

Then add this to your form:

Code:
	Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

		MyBase.WndProc(m)
		If m.Msg = 5 Then
			Me.WindowState = FormWindowState.Maximized
		End If

	End Sub


As far as I can see it is virtually impossible to totally prevent both moving and resizing without any flicker at all.

This totally prevents moving, but does not totally prevent resizing without some flicker. However, there seems to be slightly less flicker this way, than when using the FormResize event.

Note that flicker only occurs when clicking Maximize or DoubleClicking the titlebar.

As an aside, if you set MaximizeBox to False, the form becomes moveable.


Hope this helps.



[vampire][bat]
 
DOH! That's because I typed it wrong it is System.Drawing.Point

Me.Location = New System.Drawing.Point(0,0)

-I hate Microsoft!
-Forever and always forward.
 
E&f thank you once more.
I don't want any kind of flickering in no way even if the user press max button, even if he double clicks in the titlebar and i want the mdi parent form always maximized and always umovable. Also i don't want to prevent user minimize the form.
None of the above solutions could help me :(

Thanks all.
 
A windows form is simply not designed to do that on it's own. We've giving you ways to try to work around that, but it is just fighting the very nature of a window. You have to totally get rid of that. I couldn't get the API to work right with VB.net. For some reason it wouldn't always prevent the window. May be someone else might still figure it out. Other that I would say at this point your only other options are to create your own form class from scratch. You might try CodeProject someone may have already built something like that.

-I hate Microsoft!
-Forever and always forward.
 
Sorwen, I've just lost patience (and interest) with this now, especially when you consider: thread796-1458556


[vampire][bat]
 
I just thought another idea but i don't know if it would be better i am just trying to find a solution to my problem but it doesn't mean that i give up to this problem
 
Unless your program's users are going to spend all their time clicking as fast as they can on the Maximize/Restore button or double-clicking as fast as they can on the titlebar, then, to be honest you have the solution.
[tt]
Leave Maximize, Minimize and Control boxes enabled.
Set BorderStyle to one of the non-sizeable settings.
Set WindowState to Maximized.
[/tt]
and:

Code:
	Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

		If WindowState <> FormWindowState.Minimized Then WindowState = FormWindowState.Maximized

	End Sub

is all you need to do.

If you want to be clever, then you need to trap mouse clicks etc. on the titlebar. It can be done - but there is no guarantee that the effects will be any different, and the amount of work will be horrendous.

The flicker resulting from my suggestion ranges between none and minimal. If that is not good enough for you then .....



[vampire][bat]
 
Thank you again E&f but this is not what i want. I have explained it so many times, but maybe this is not possible to do it. Doesn't matter thanks everyone for your help.
The other solution i have posted in thread796-1458556 i just thought it this time and thought without knowing if its a good idea, but finally i think it is, as i can't find here the what i want to do. And i was just wanted to have an integral opinion. Also the problem of flickering still exists with this solution too. And finally i will follow the solution my thought in thread796-1458556 and i hope to find somenone to help me solve my problem. Thanks everyone again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top