#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    1
    Rep Power
    0

    TShape problem in Borland C++


    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:

    Code:
    Shape2->Top = Shape1->Top;
    Shape2->Left = Shape1->Left;
    I need a simple solution like this one:

    Code:
    Shape2->Position = Shape1->Position;
    I have tried to use ClientToScreen and ClientOrigin and stuff like that to get the point of the shape, but I donīt know how to use them.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    Originally Posted by Mattiaz
    NOT like this:

    Code:
    Shape2->Top = Shape1->Top;
     Shape2->Left = Shape1->Left;
    Why not? If you really need it in one line, you could derive your own TMyShape from T(Custom?)Shape and add eg. "TPoint ::GetPosition()" and "SetPosition(TPoint)" methods, but this is probably too much overhead compared to using the two lines from above...

    HTH,
    M.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    3
    Rep Power
    0
    Try

    SetBounds(int ALeft, int ATop, int AWidth, int AHeight);

    Sets the Left, Top, Width, and Height properties all at once.

IMN logo majestic logo threadwatch logo seochat tools logo