Solved

Reading X,Y-pos while moving Form

Posted on 2000-02-16
11
151 Views
Last Modified: 2010-04-04
I'm trying to get the windows X,Y pos while moving the form.
The movement is initiated through performing wm_syscommand.
Like this:  form.Perform(WM_Syscommand,$F012,0);

I tried Using the WM_WindowPosChanging Message to read the pos, but i can't figure it out.

Any help appreciated

Raidos
0
Comment
Question by:raidos
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 3

Expert Comment

by:ckaneta
Comment Utility
here's a hint, when you move a form it gets repainted, too
0
 
LVL 6

Expert Comment

by:edey
Comment Utility
or you could trap the WM_MOVING message

GL
Mike
0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
Here it is:

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure Move(var Message: TWMChar); message WM_MOVE;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Move(var Message: TWMChar);
begin
  Caption := IntToStr(Left);
//  Caption := IntToStr(Top);
end;
0
 
LVL 6

Expert Comment

by:edey
Comment Utility
note, WM_MOVE is fired *after* the window has moved

GL
Mike
0
 
LVL 3

Author Comment

by:raidos
Comment Utility
Hmm, thanks for your comments.

Allthough this is not really what i'm looking for.
I need to read the pos of the forms Outline that
gets displayed while moving the form

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:bryan7
Comment Utility
listenning
0
 
LVL 3

Expert Comment

by:ckaneta
Comment Utility
question: do you have it set up so a user can only drag from the titlebar or from anywhere on the form?

either way, I guess it would work the same, so here's another idea...
get the mousepos, save the forms top and left positions, and set a flag on an LButton down event, on a if the flag is set when you get a Move message, calculate the outlines top, and left from the forms old top and left from the current position of the mouse.

0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
Ahh... you have 'Show window contents while dragging' turned off.... right?
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
euhm, why not using the WM_MOVING message?

Thus eventually the same solution as Epsylons, but use WM_MOVING instead of WM_MOVED...

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
  protected

 procedure FormMoving(var MSG : TMessage); message WM_MOVING ;

  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormMoving(var Msg: TMessage);
begin
  inherited;
  showmessage('New form position : '+inttostr(left)+','+inttostr(top));

end;


end.
0
 
LVL 3

Author Comment

by:raidos
Comment Utility
Found a solution to my problem
I goes like so:

Procedure WMMoving(Var Message: TMessage);
Var
  Wpos : Prect;
Begin
  WPos := Pointer(Message.LParam);
  If WPos.Left < 10 then Begin
    WPos.Left := 0;
    WPos.Right := Form.Width;
  End;
  Inherited;
End;

Now, how should i post the points?
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
Comment Utility
Just grade it  :o)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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