Solved

Reading X,Y-pos while moving Form

Posted on 2000-02-16
11
159 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
ID: 2528509
here's a hint, when you move a form it gets repainted, too
0
 
LVL 6

Expert Comment

by:edey
ID: 2528558
or you could trap the WM_MOVING message

GL
Mike
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2528578
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:edey
ID: 2528603
note, WM_MOVE is fired *after* the window has moved

GL
Mike
0
 
LVL 3

Author Comment

by:raidos
ID: 2528643
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
 
LVL 3

Expert Comment

by:bryan7
ID: 2528667
listenning
0
 
LVL 3

Expert Comment

by:ckaneta
ID: 2528698
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
ID: 2528785
Ahh... you have 'Show window contents while dragging' turned off.... right?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2528797
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
ID: 2528929
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
ID: 2531755
Just grade it  :o)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi IDE crash without error message ... 7 113
Delphi 2 77
Unique identifier on a terminal server (rdp) 4 73
how to resize animated Gif image in delphi ? 1 45
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 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