I want to prevent the user from moving the winform. How do you lock or freeze the winform's location? So, that no matter what they do, it can't be moved. I think, for win32 you have a frozen option for windows. When this option is set, you only see the outline of the windows being moved but the actual window is still in its original location. I am trying to do a similar thing with winform.
EDIT: Here is a procedure to capture window message for position change in win32:
//Frozen is a user-defined boolean variable
procedure TVIewFrm.WMPosChanging(var Msg: TMessage);
var
wp:PWINDOWPOS;
begin
if Frozen then
begin
wp := PWINDOWPOS(Msg.lParam);
wp^.flags := wp^.flags or SWP_NOMOVE;
end;
inherited;
end;
That is a working procedure and that is what I am trying to do with the WinForm. So far you all posted a work around not really the solution I am looking.
Although some of you came close, it just didn't work for me. Your answers were more or less work around. I was looking for a straight forward solution.
I figured out my issue. Although my solution works flawlessly, it doesn't draw and drag an outline of the winform. I probably have to implement code similar to LarsTech to achieve that.
Here is my working code:
//declared within a form class under protected
method WndProc(var m:Message); override;
//and is defined as follows.
method MainForm.WndProc(var m: Message);
const WM_NCLBUTTONDOWN = 161;
const WM_SYSCOMMAND = 274;
const HTCAPTION = 2;
const SC_MOVE = 61456;
begin
if ((m.Msg = WM_SYSCOMMAND) and (m.WParam.ToInt32 = SC_MOVE)) then
begin
exit;
end;
if ((m.Msg = WM_NCLBUTTONDOWN) and (m.WParam.ToInt32 = HTCAPTION)) then
begin
exit;
end;
inherited WndProc(var m);
end;
Thank you all for your answers.