LCL, fixed TabIndexAtClientPos for win32 and gtk2

git-svn-id: trunk@18831 -
This commit is contained in:
jesus 2009-02-27 03:23:46 +00:00
parent d165265aaa
commit af721847eb
2 changed files with 14 additions and 1 deletions

View File

@ -527,13 +527,23 @@ var
TabWidget: PGtkWidget;
PageWidget: PGtkWidget;
NotebookPos: TPoint;
Window: PGdkWindow;
WindowOrg,ClientOrg: TPoint;
Count: guint;
begin
Result:=-1;
NoteBookWidget:=PGtkNotebook(ANotebook.Handle);
if (NotebookWidget=nil) then exit;
//DebugLn(['TGtkWSCustomNotebook.GetTabIndexAtPos ',GetWidgetDebugReport(PGtkWidget(NotebookWidget))]);
{$IFDEF GTK2}
Window := GetControlWindow(NoteBookWidget);
gdk_window_get_origin(Window,@WindowOrg.X,@WindowOrg.Y);
ClientOrg:=GetWidgetClientOrigin(PGtkWidget(NotebookWidget));
NotebookPos.X:= AClientPos.X + (ClientOrg.X-WindowOrg.X);
NotebookPos.Y:= AClientPos.Y + (ClientOrg.Y-WindowOrg.Y);
{$ELSE}
NotebookPos:=AClientPos;
{$ENDIF}
// go through all tabs
Count:=g_list_length(NoteBookWidget^.Children);
for i:=0 to Count-1 do begin

View File

@ -610,8 +610,11 @@ class function TWin32WSCustomNotebook.GetTabIndexAtPos(const ANotebook: TCustomN
const AClientPos: TPoint): integer;
var
hittestInfo: TC_HITTESTINFO;
Orect: TRect;
begin
hittestInfo.pt := AClientPos;
GetLCLClientBoundsOffset(ANotebook, ORect);
hittestInfo.pt.x:= AClientPos.x + ORect.Left;
hittestInfo.pt.y:= AClientPos.y + ORect.Top;
Result := Windows.SendMessage(ANotebook.Handle, TCM_HITTEST, 0, LPARAM(@hittestInfo));
end;