Solved

prevent a form from moving

Posted on 2002-05-21
4
788 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 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