View Issue Details

IDProjectCategoryView StatusLast Update
0038403LazarusLCLpublic2021-02-28 08:33
ReporterCudaText man_ Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWin10 x64 
Product Version2.1 (SVN) 
Target Version2.2Fixed in Version2.2 
Summary0038403: TTabControl.IndexOfTabAt is always -1, with a hack p.y:=-5 it works
Descriptiondemo attached.
it shows PageControl - for it, mouse move shows OK tab index in caption.
if shows TabControl - for it, mouse move shows always -1 index in caption.

if you make hack from
https://bugs.freepascal.org/view.php?id=27467
and set
  p.y:= -5
before the
  n:=TabControl1.IndexOfTabAt(p);
then it will work.
TagsNo tags attached.
Fixed in Revision64424,64436,64677
LazTarget2.2
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0027467 resolvedMichl Lazarus TTabControl.IndexOfTabAt() always returns -1 
parent of 0038409 closedMartin Friebe Packages Error when building LCLBase 
parent of 0038422 closedMartin Friebe Lazarus TTabControl fix in r64424 broke the CudaText 

Activities

CudaText man_

2021-01-26 18:21

reporter  

Anton Kavalenka

2021-01-26 20:27

reporter   ~0128604

P have to be control-relative or screen-relative?

Bart Broersma

2021-01-27 11:07

developer   ~0128612

And does that hack also work if TabPosition <> tpTop?
And (again), please attach a proper patch instead of the "instructions" you gave.

Martin Friebe

2021-01-27 12:55

manager   ~0128616

P.Y:=-5 will NOT work for multiline tabs (wrapped tabs).

Martin Friebe

2021-01-27 13:14

manager   ~0128617

First of all it needs to be checked that windows handles the client-rect for the tabcontrol the same way as for the pagecontrol.

If so, the correct code can be found here
B:\lazarus_latest_svn_2\lcl\interfaces\win32\win32pagecontrol.inc line 398..407
  if not (AWinControl is TTabControl) then begin
...
    Params.WindowInfo^.ClientOffsetProc := @TabControlClientOffset;

TabControlClientOffset gets the offset between the outer and inner bounds rect.

For some reason it was decided that this code does NOT apply to TTabControl.
However it is well possible that the line in question was accidentally put into the if block. (may be worth checking svn history)

Martin Friebe

2021-01-27 14:03

manager   ~0128620

Please test and close if ok.

Martin Friebe

2021-01-27 14:05

manager   ~0128621

Btw, I do not know what Delphi does.
It is also possible to have an Origin of zero, and apply the diff only when performing actions on the child-tab-control (such as getting the tab index).

Martin Friebe

2021-01-29 19:56

manager   ~0128658

Moving the origin has side-effect (user placed child controls of the TTabControl). This breaks backward compatibility (as all those children would move by the new offset)

Reverted, and apply the offset only when querying the tab-index.

Joeny Ang

2021-02-24 07:59

reporter   ~0129133

Hi, before this patch, TTabControl.IndexOfTabAt() works if you pass the X/Y params of the MouseMove event (which has a negative Y, similar to TPageControl). Now, it always returns -1. The problem might be in TTabControl.ScreenToClient(Mouse.CursorPos), which returns a positive Y. Inside the MouseMove event, the params X/Y should be similar to the point returned by TTabControl.ScreenToClient(Mouse.CursorPos).

CudaText man

2021-02-24 08:45

reporter   ~0129135

Let's reopen the issue then?

Bart Broersma

2021-02-24 09:45

developer   ~0129137

Seems to cause a regression?

Martin Friebe

2021-02-27 03:26

manager   ~0129190

Last edited: 2021-02-27 03:41

View 2 revisions

Interesting, the message.x/y start at -20 (depends) go to 0, then jump to +20
....
If the tabs are at the bottom, then Y starts at 0 again.
Making the y range from 0..20 ambiguous, is it occurs in the client above, and on the tabs.
(That is if you make the height of the TTabControl big enough to have free space above the tabs)

Similar for X with tabs on the right.

Martin Friebe

2021-02-27 03:49

manager   ~0129191

@Joeny Ang

I plan to adjust the values in the mouse coordinates, so they can be used again (directly passed through).

This should then also fix that there currently are two points 0,0 in the TTabControl. (tabs at bottom)

Martin Friebe

2021-02-27 17:08

manager   ~0129208

Fixed Mouse-event x/y in rev 64677
They now report relative to the TabControl. They will no longer be negative.

Fore more details see:
https://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes#ShortcutToText_.2F_TextToShortcut

CudaText man

2021-02-27 21:01

reporter   ~0129211

good work, thanks!

Joeny Ang

2021-02-28 08:33

reporter   ~0129221

Great! Works now. Thanks!

Issue History

Date Modified Username Field Change
2021-01-26 18:21 CudaText man_ New Issue
2021-01-26 18:21 CudaText man_ File Added: tst-tabcontrol-tabindex.zip
2021-01-26 18:40 Juha Manninen Relationship added related to 0027467
2021-01-26 20:27 Anton Kavalenka Note Added: 0128604
2021-01-27 11:07 Bart Broersma Note Added: 0128612
2021-01-27 11:07 Bart Broersma Status new => feedback
2021-01-27 11:07 Bart Broersma LazTarget => -
2021-01-27 12:55 Martin Friebe Note Added: 0128616
2021-01-27 13:14 Martin Friebe Note Added: 0128617
2021-01-27 14:03 Martin Friebe Assigned To => Martin Friebe
2021-01-27 14:03 Martin Friebe Status feedback => resolved
2021-01-27 14:03 Martin Friebe Resolution open => fixed
2021-01-27 14:03 Martin Friebe Fixed in Version => 2.2
2021-01-27 14:03 Martin Friebe Fixed in Revision => 64424
2021-01-27 14:03 Martin Friebe LazTarget - => 2.2
2021-01-27 14:03 Martin Friebe Widgetset Win32/Win64 => Win32/Win64
2021-01-27 14:03 Martin Friebe Note Added: 0128620
2021-01-27 14:05 Martin Friebe Note Added: 0128621
2021-01-27 17:09 Martin Friebe Relationship added parent of 0038409
2021-01-29 19:21 Martin Friebe Relationship added parent of 0038422
2021-01-29 19:56 Martin Friebe Fixed in Revision 64424 => 64424,64436
2021-01-29 19:56 Martin Friebe Widgetset Win32/Win64 => Win32/Win64
2021-01-29 19:56 Martin Friebe Note Added: 0128658
2021-02-24 07:59 Joeny Ang Note Added: 0129133
2021-02-24 08:45 CudaText man Note Added: 0129135
2021-02-24 09:45 Bart Broersma Status resolved => assigned
2021-02-24 09:45 Bart Broersma Resolution fixed => open
2021-02-24 09:45 Bart Broersma Note Added: 0129137
2021-02-26 15:55 Martin Friebe Target Version => 2.2
2021-02-26 15:55 Martin Friebe Widgetset Win32/Win64 => Win32/Win64
2021-02-27 03:26 Martin Friebe Note Added: 0129190
2021-02-27 03:41 Martin Friebe Note Edited: 0129190 View Revisions
2021-02-27 03:49 Martin Friebe Note Added: 0129191
2021-02-27 17:08 Martin Friebe Status assigned => resolved
2021-02-27 17:08 Martin Friebe Resolution open => fixed
2021-02-27 17:08 Martin Friebe Fixed in Revision 64424,64436 => 64424,64436,64677
2021-02-27 17:08 Martin Friebe Widgetset Win32/Win64 => Win32/Win64
2021-02-27 17:08 Martin Friebe Note Added: 0129208
2021-02-27 21:01 CudaText man Note Added: 0129211
2021-02-28 08:33 Joeny Ang Note Added: 0129221