?
Solved

prevent a form from moving

Posted on 2002-05-21
4
Medium Priority
?
796 Views
Last Modified: 2012-08-14
Hi there,

I have an MDI child form and I want to implement a "lock window" command so that the user can't move the form around. I thought this should be done with TWMWindowPosChanging and/or TWMMove but I can't get it to work. Anyone knows how to do this?

Bye,
Jeroen
0
Comment
Question by:jccommandeur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:raidos
ID: 7024171
I don't know if this works with MDI children but i those are windows too, so i guess it would work..


Hook the WM_MOVING Message

INTERFACE

Procedure WMMOVING(Var Msg: TMessage); Message WM_MOVING;

IMPLEMENTATION

Procedure TForm1.WMMOVING(Var Msg: TMessage);
Var
  aRect : PRect;
Begin
  aRect := Pointer(Msg.lParam);
  aRect.Left := 10;
  aRect.Top := 10;
  aRect.Right := 100;
  aRect.Bottom := 100;
End;

Hope it works..=)

Regards
//raidos
0
 
LVL 3

Expert Comment

by:raidos
ID: 7024178
i cant speak english today, it seems..=/

but i those ?

but those !

ohh well...
0
 

Author Comment

by:jccommandeur
ID: 7024286
Hi,

Seems like it, but it doesn't work yet. I've been experimenting with these kind of routines all day. All I want is to move the mdi child form to some position, press 'lock window' and then I can't move the form anymore (it stays in its current position).

Bye,
Jeroen
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 200 total points
ID: 7024668
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure WMPosChange(var Message: TWMWindowPosChanging);
       message WM_WINDOWPOSCHANGING;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.WMPosChange(var Message: TWMWindowPosChanging);
begin
     with PWindowPos(TMessage(Message).lParam)^ do
       Flags:=Flags or SWP_NOMOVE or SWP_NOSIZE;
end;

end.



this works :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question