Solved

prevent a form from moving

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
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…

726 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