×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Absolute position of a TComponent

Absolute position of a TComponent

Absolute position of a TComponent

(OP)
Hello everybody.

My question is: Is there any way to read the absolute position in screen of a TComponent, for instance, a TImage?

The Top property is not useful for me. If it is 0, the component is in the relative position 0 of the TForm, but it is not the 0 absolute position in screen... (It depends on factors such as the title window height).

Thank you very much.

RE: Absolute position of a TComponent

(OP)
No responses??

Plz I need help :(

RE: Absolute position of a TComponent

Perhaps you can synthesize the absolute position of a TImage in a screen.  You do have access to the TForm's absolute position in the screen, so if you can determine the title window height, etc... you can determine the absolute position of a TImage.

Steve.

RE: Absolute position of a TComponent

(OP)
Thanks Steve,

but my problem is that i cannot determinate the height of the title window.

I can have the window in the position Top 0 and the TImage also in the position Top 0 (relative). If I knew the height of the title window the calculation of the absolute height position of the TImage would be as simple as:

abs_pos_h=TForm->Top+TitleWindowHeight+TImage->Top;

But I really do not know the height of the title window and I do not if it is possible to get it in some way, or calculate it.

Do you know how can get the height of the title window??

Thank you very much.

RE: Absolute position of a TComponent

I guess if I was responsible for doing this sort of thing, I can think of five different things I would try:

1.)  Experiment with title window heights:  try 1, then try 2,...
2.)  Remove the title bar altogether.
3.)  Post this same question in the CodeGear(Borland) Delphi forum in www.tek-tips.com
4.)  Post this question on www.bcbjournal.org
5.)  Explore the more of the TScreen class for some clues.


Sorry I am not being much help.

Steve.

RE: Absolute position of a TComponent

Look at the Win32 API FindWindowEx() and GetWindowRect() function calls.

I believe the title bar is considered a child window (?), in which case perhaps you can get the dimensions of your title window(?).

Steve.

RE: Absolute position of a TComponent

I think you might want check into the windows API function call ClientToScreen.   

RE: Absolute position of a TComponent

place in a TForm an TImage and a TButtom.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TPoint point;
  point = Image1->ClientToScreen(TPoint(0,0));
  ShowMessage(AnsiString(point.x)+" "+AnsiString(point.y));
}

When you move the frame an push the buttom you will get the
absolute position.

If you replace Image1 with this (or Form1), you will get the absolute
position of the Form1

RE: Absolute position of a TComponent

(OP)
Thanks to you all, the ClientToScreen function is exactly what I was looking for.

Thank you!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close