|
Question : Immovable Form
|
|
I want to prevent a window from being moved. therefore, I need the ff: 1. Clicking and dragging the titlebar of a form does not move the form 2. The "Move" option, from the popup that appears when you press "Alt-spacebar" or when you click the icon on the titlebar, is also disabled. 3. Should also work with MDI child forms
I've tried a few solutions, but I didn't quite like the results even if it achieved the main goal of keeping the form in place. I've tried the ff: 1. Set the Form.Location to its original value during the Form.LocationChanged event. 2. Set the Form.Location to its original value during the Form.Move event. 3. Set the Form.Capture = false in an overriden WndProc() 4. Change the Message.LParam values in an overriden WndProc()
Unfortunately, some of the solutions tend to give a flicker effect. Solutions #1 and #2 still display the dotted rectangle while you drag the form, indicating the form is being moved. Solution #4 does not work well with MDi child forms. And none of the solutions can disable the "Move" option in the popup box.
In other works, I'm not looking for a workaround. I'm looking for a "setting" that makes the form immovable (but still resizable, just in case someone jumps in by saying FormBorderStyle.None =) ).
I prefer answers in C#.NET or VB.NET (my main language is c#, but I can translate from vb fine. i'm not sure about c++ though as i've never tried.)
Thank you all!
|
|
Answer : Immovable Form
|
|
From the Help:
In Visual Basic 6.0, the Moveable property of a form could be set to false to prevent a user from moving the form at run time. Windows Forms in Visual Basic .NET do not have an equivalent property.
Although it is generally considered bad user interface design, you can achieve similar behavior in Visual Basic .NET by setting the Form.FormBorderStyle property to none and the Form.ControlBox property to false.
|
|
|
|