Solved

prevent a form from moving

Posted on 2002-05-21
4
787 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
  • 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now