Click to See Complete Forum and Search --> : prevent move or resizing of MDI child
venAdder
February 28th, 2006, 02:11 PM
Hi,
I have an MDI application and I don't want the user to move or resize any of the child forms, i'e they need to have fixed size and location.
I put fals eon contorl box, but they still can move and resize.
Now i put some code in resize and move event sto prevent this successfully, but it's not elegent. There's lot of flickering when user has the mouse down and is attempting to move or resize.
Is there soem nicer way to accomplish this, which won't look shabby like with all the flickering.
aniskhan
February 28th, 2006, 10:24 PM
to make the child unresizable change
formBorderSize = fixedToolWindow
minimizeBox = false
maximizeBox = false
to make the form imMoveable get this SystemMenuManager (http://www.vbforums.com/showthread.php?t=351533) class
add code to form load
Dim myMenuManager As New SystemMenuManager(Me, False, SystemMenuManager.MenuItemState.Greyed)
hope u got it
venAdder
March 1st, 2006, 03:26 PM
Thanks for you reply.
The sizing probblem is fixed. But the moving isn't by using your exmaple.
What I want is when someone click ont eh caption(title) bar of the form ( the control box is set to false ) and try to move form by dragging it , he should not be able to do so.
what i did was:
Private Sub CForm_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
If Not mMove Then Me.Location = mRect.Location
End Sub
where mRect has been initiliazed to an area. This works but it produce the flickering effect.
i tried you way by using that lien of code, but that dosn't stop em from draggin the form in MDI client area to where i want to
Thanks again fot the reply
venAdder
March 1st, 2006, 03:27 PM
One additional question. Is there a way to get rid of the title bar altogether, so that all i have in a form is the client area
aniskhan
March 2nd, 2006, 05:00 AM
set the form text property empty and controlBox property to false ,u will have only the client area.
HanneSThEGreaT
March 2nd, 2006, 07:43 AM
what i did was:
Private Sub CForm_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
If Not mMove Then Me.Location = mRect.Location
End Sub
where mRect has been initiliazed to an area. This works but it produce the flickering effect.
Just for interest sake.. I had a similar problem in moving forms, what I managed to do was use this code to remove the flickering.
'Declarations
'constants to move form
Private Const WM_NCHITTEST As Integer = &H84
Private Const HTCLIENT As Integer = &H1
Private Const HTCAPTION As Integer = &H2
'move form
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_NCHITTEST 'to drag
MyBase.WndProc(m)
If (m.Result.ToInt32 = HTCLIENT) Then 'client
m.Result = IntPtr.op_Explicit(HTCAPTION) 'name of window
End If
Exit Sub
End Select
MyBase.WndProc(m)
End Sub
I know you're looking for a way to prvent people from moving the form, but since you mentioned the flickering effect, I thought to post this to prevent the flickering event.
FrameTech
March 18th, 2006, 09:06 AM
One additional question. Is there a way to get rid of the title bar altogether, so that all i have in a form is the client area
Wouldnt you simply set the "FormBorderStyle" in the Properties window to "None" That will give you a smooth (no border at all) finish.
gigemboy
March 18th, 2006, 09:47 AM
Very good Frametech :) I was going to suggest the same, as I have done it that way before :thumb:
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.