Click here to Skip to main content
16,013,730 members
Home / Discussions / C#
   

C#

 
QuestionHow to make a form unmovable? Pin
gshen24-Apr-07 10:39
gshen24-Apr-07 10:39 
AnswerRe: How to make a form unmovable? Pin
Dan Neely24-Apr-07 10:49
Dan Neely24-Apr-07 10:49 
GeneralRe: How to make a form unmovable? [modified] Pin
gshen24-Apr-07 10:56
gshen24-Apr-07 10:56 
AnswerRe: How to make a form unmovable? Pin
Mazdak24-Apr-07 11:49
Mazdak24-Apr-07 11:49 
GeneralRe: How to make a form unmovable? Pin
gshen24-Apr-07 12:44
gshen24-Apr-07 12:44 
GeneralRe: How to make a form unmovable? Pin
MoustafaS24-Apr-07 13:07
MoustafaS24-Apr-07 13:07 
GeneralRe: How to make a form unmovable? Pin
gshen24-Apr-07 13:13
gshen24-Apr-07 13:13 
GeneralANSWER: Re: How to make a form unmovable? Pin
Patrick Etc.24-Apr-07 15:20
Patrick Etc.24-Apr-07 15:20 
The WM_MOVE message merely informs the window that it is being moved - it is not a request to move.

This code works for me. Put it in your form and it should work.

public const int WM_MOVE = 0x216;
private bool m_AllowMove = false;

[StructLayoutAttribute(LayoutKind.Sequential)]
public struct WM_MOVERECT
{
    public int Left,Top,Right,Bottom;
}

protected override void WndProc(ref Message m)
{
    if(!m_AllowMove)
    {
        if(m.Msg == WM_MOVE)
        {
            WM_MOVERECT lParam = (WM_MOVERECT)m.GetLParam(typeof(WM_MOVERECT));
            lParam.Left = this.Left;
            lParam.Top = this.Top;
            lParam.Right = this.Right;
            lParam.Bottom = this.Bottom;

            Marshal.StructureToPtr(lParam, m.LParam, true);
        }
    }

    base.WndProc(ref m);
}


Just change m_AllowMove to true or false to suit your needs.

Enjoy.




------------
Cheers,
Patrick

GeneralRe: ANSWER: Re: How to make a form unmovable? Pin
gshen25-Apr-07 6:21
gshen25-Apr-07 6:21 
AnswerRe: How to make a form unmovable? Pin
MoustafaS24-Apr-07 12:58
MoustafaS24-Apr-07 12:58 
GeneralRe: How to make a form unmovable? Pin
gshen24-Apr-07 13:02
gshen24-Apr-07 13:02 
QuestionAuthenticate windows local account without using active directory! Pin
Adeel Chaudhry24-Apr-07 10:34
Adeel Chaudhry24-Apr-07 10:34 
QuestionQuestion about RichTextBox Pin
Adobe200724-Apr-07 10:24
Adobe200724-Apr-07 10:24 
AnswerRe: Question about RichTextBox Pin
Patrick Etc.24-Apr-07 15:25
Patrick Etc.24-Apr-07 15:25 
GeneralRe: Question about RichTextBox Pin
Adobe200724-Apr-07 17:19
Adobe200724-Apr-07 17:19 
GeneralRe: Question about RichTextBox Pin
7124-Apr-07 18:57
7124-Apr-07 18:57 
Questionsending class objects over netowks [modified] Pin
_tasleem24-Apr-07 9:05
_tasleem24-Apr-07 9:05 
AnswerRe: sending class objects over netowks Pin
Patrick Etc.24-Apr-07 15:26
Patrick Etc.24-Apr-07 15:26 
GeneralRe: sending class objects over netowks Pin
_tasleem25-Apr-07 3:30
_tasleem25-Apr-07 3:30 
GeneralRe: sending class objects over netowks Pin
Patrick Etc.25-Apr-07 4:02
Patrick Etc.25-Apr-07 4:02 
QuestionC# 2005 Express Edition - Report Pin
msogun24-Apr-07 8:55
msogun24-Apr-07 8:55 
AnswerRe: C# 2005 Express Edition - Report Pin
Dave Kreskowiak24-Apr-07 11:43
mveDave Kreskowiak24-Apr-07 11:43 
QuestionC# resource file Pin
netJP12L24-Apr-07 8:51
netJP12L24-Apr-07 8:51 
QuestionColor Eraser....!! Pin
mr jets24-Apr-07 8:40
mr jets24-Apr-07 8:40 
AnswerRe: Color Eraser....!! Pin
Paul Conrad24-Apr-07 13:49
professionalPaul Conrad24-Apr-07 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.