Solved

prevent a form from moving

Posted on 2002-05-21
4
786 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
Comment Utility
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
Comment Utility
i cant speak english today, it seems..=/

but i those ?

but those !

ohh well...
0
 

Author Comment

by:jccommandeur
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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