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
Solved

Reading X,Y-pos while moving Form

Posted on 2000-02-16
11
156 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
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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 93
add combobox item based on numbers 9 154
Intraweb download file link ? 1 153
TServerSocket - file via sendbuf or Text via sendtext ? 1 65
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

789 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