Click to See Complete Forum and Search --> : How to store position of an object?


Mattiaz
March 17th, 2004, 05:52 PM
I have a TShape object on a form and I want to store itīs Top and Left positions. Then if I add one more shape object to my app and want it to have the same position as the first shape, how can I do it easily??

NOT like this:

Shape2->Top = Shape1->Top;
Shape2->Left = Shape1->Left;

I need something like:

Shape2->Position = Shape1->Position;

RussG1
March 17th, 2004, 09:38 PM
I do not know what a TShape is (I suspect it is some Borland Class), but you can use GetWindowRect() to get screen coordinates of the corners of your control, and then use that info to position the second control using MoveWindow() or SetWindowPos().