Recent

Author Topic: TPageControl.TabRect(?) seems to return incorrect information?  (Read 1203 times)

jamie

  • Hero Member
  • *****
  • Posts: 7702
As the title states.

  The values being returned does not seem match what a windows platform would return?
 
   Using the standard method of obtaining this information in windows.

Code: Pascal  [Select][+][-]
  1. SendMessage(PageConrol.Handle, TCM_GETITEMRECT, PageControl.TabIndex, UintPtr(@TheRectangleThatReceivesIt));
  2.  

 The values here are exactly as expected for top taps and precisely dead on.
 They also work well for bottom one's too.

 What does not work well is the TabRect which returns incorrect values. They are negative and even if you flip them around, they are still wrong. The information return does not align with the tabs no matter what you do unless you add a little here and there, which makes little sense.

can someone verify this please?
The only true wisdom is knowing you know nothing

Joanna

  • Hero Member
  • *****
  • Posts: 1450
Re: TPageControl.TabRect(?) seems to return incorrect information?
« Reply #1 on: April 12, 2023, 12:33:57 pm »
Hi everyone
Jamie came to irc today and we talked about this issue.
I tested it also and trect() function returned a rectangle that had Erroneous looking values such as a top property of -23 which definitely seems strange being that the tabsheet was within visible in upper left corner of frame.

There is one thing I just thought of. If the values are always off by the same amounts maybe figure out what the offsets are and correct the rectangle values. :D
An even better idea would be to find out what is doing this and fix it...beyond my skill level unfortunately  %)

Can anyone else test please ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12345
  • Debugger - SynEdit - and more
    • wiki
Re: TPageControl.TabRect(?) seems to return incorrect information?
« Reply #2 on: April 12, 2023, 12:47:19 pm »
The negative values (at least for y, if tabs or shown on top) are correct. (afaik)

There is a value (not sure of the name) something like client-origin, which shifts the entire coordinates.
This is, so that the client-rect of the page (not sure if with or without any borders) starts at y=0).

If you call ClienstToScreen that should be taken into account... (IIRC)

Joanna

  • Hero Member
  • *****
  • Posts: 1450
Re: TPageControl.TabRect(?) seems to return incorrect information?
« Reply #3 on: April 12, 2023, 04:23:02 pm »
Thanks for clarifying. I would really like to be able to control the color of the tabrect. Does anyone know how?

jamie

  • Hero Member
  • *****
  • Posts: 7702
Re: TPageControl.TabRect(?) seems to return incorrect information?
« Reply #4 on: April 13, 2023, 12:47:35 am »
Something to play with..
The only true wisdom is knowing you know nothing

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12345
  • Debugger - SynEdit - and more
    • wiki
Re: TPageControl.TabRect(?) seems to return incorrect information?
« Reply #5 on: April 13, 2023, 09:59:51 am »
You probably need to draw your own tabs (or use a custom drawn solution / IIRC there is ATTabs).

Windows will always return the same rect (and I know no way around that). But if you look very closely, if you click an not-yet active tab, then its surrounding border moves (the tab slightly grows (not just in height, but also left/right).


jamie

  • Hero Member
  • *****
  • Posts: 7702
Re: TPageControl.TabRect(?) seems to return incorrect information?
« Reply #6 on: April 14, 2023, 01:17:10 am »
Ok, I've studied this a little more and it seems that DC is gaining an Offset to its region after it returns from the original
handler and then my code follows through.

 The TabRect is forcing it off the sheet because now the DC points to the actual TabSheet surface, not the whole Page control surface. Or at least it has an offset region and new clipping applied to it using the paint handler for the Page Control instead of using the actual paint handler for the tab sheet.
 
  I just don't remember it working this way, maybe it did but these controls are basically like a Combo box where they have two controls within one.

 I won't get into this anymore but maybe someone with more time can check the results against a recent Delphi install.


 Also, I believe this should be documented as a negative offset from the Tabsheet not the client of the page control.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018