Solved

Reading X,Y-pos while moving Form

Posted on 2000-02-16
11
162 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
[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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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