disable user moving application window?

  • Thread starter Thread starter ST Choong
  • Start date Start date
S

ST Choong

I am using the following code to disable user to move my application in C++.
How to do it in C#?
Thanks.
void CMainFrame::OnSysCommand( UINT nID, LPARAM lParam )

{

if( (nID & 0xfff0) == SC_MOVE || (nID & 0xfff0) == SC_SIZE || (nID & 0xfff0)
== SC_RESTORE)

return;

CMDIFrameWnd::OnSysCommand(nID, lParam);

}
 
I am using the following code to disable user to move my application
in C++. How to do it in C#?
Thanks.
void CMainFrame::OnSysCommand( UINT nID, LPARAM lParam )

{

if( (nID & 0xfff0) == SC_MOVE || (nID & 0xfff0) == SC_SIZE || (nID &
0xfff0) == SC_RESTORE)

return;

CMDIFrameWnd::OnSysCommand(nID, lParam);

}

Override your WndProc() procedure, and tjeck for the Message.Msg id-number

pseudo:

protected override WndProc(ref Message m) {
switch (m.Msg) {
case: 1:

return;
break;
}

base.WndProc(m);
}

/Pauli
 
Pauli said:
Override your WndProc() procedure, and tjeck for the Message.Msg id-number

To make it a little clearer:

protected override void WndProc(ref Message message)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;

switch(message.Msg)
{
case WM_SYSCOMMAND:
int command = message.WParam.ToInt32() & 0xfff0;
if (command == SC_MOVE)
return;
break;
}

base.WndProc(ref message);
}

Greetings,
timtos.
 
Thanks. I got it working.


timtos said:
To make it a little clearer:

protected override void WndProc(ref Message message)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;

switch(message.Msg)
{
case WM_SYSCOMMAND:
int command = message.WParam.ToInt32() & 0xfff0;
if (command == SC_MOVE)
return;
break;
}

base.WndProc(ref message);
}

Greetings,
timtos.
 
Back
Top