• Jon © (26.09.10 14:10) [0]
    With a Tabontrol, how can I assign each tab a different tooltip?
  • Vladimir Kladov © (26.09.10 16:26) [1]
    Why not. Pages[0].Hint := '000000'; Pages[1].Hint := '11111111';
  • Jon © (26.09.10 18:16) [2]
    I tried Pages[x].Hint.Text := 'xxx' but that gives the main tab body the tooltip - I want the tab header to have a tooltip. Is that possible?

    Also, how can I obtain which tab a control is placed on?


    program TabTest;

    uses
     Windows, Messages, KOL;

    var
     TabControl: PControl;
     i: Integer;

    procedure EditboxChange(Dummy: Pointer; Sender: PControl);
    begin
     Sender.Parent.Caption := Sender.Caption; // Sender.Parent is incorrect?
     Sender.Parent.Hint.Text := Sender.Caption;
     //  TabControl.TC_Items[0] := Sender.Caption; // Works but do not know page
     //  TabControl.TC_Pages[0].Hint.Text := Sender.Caption;
    end;

    begin
     Applet := NewForm(nil, '');
     TabControl := NewTabControl(Applet, [], [], nil, 0).SetAlign(caClient);
     for i := 0 to 9 do
       with NewEditbox(TabControl.TC_Insert(i, Int2Str(i), 0), [])^ do
         OnChange := TOnEvent(MakeMethod(nil, @EditboxChange));
     Run(Applet);
    end.



    I cannot use TabControl.CurIndex because some tabs have controls which update independently.
  • Jon © (28.09.10 04:06) [3]
    I was able to make a workaround for the VCL, but KOL has problems
    The KOL tooltips are correct but they constantly flash and update.
    Can someone please test and let me know if there is a way to stabilise the hints:


    program TabTest;

    uses
     Windows, Messages, KOL;

    var
     TabControl: PControl;
     i: Integer;

    procedure MouseMove(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
    var
     TabIndex: Integer;
    begin
     TabIndex := TabControl.TC_TabAtPos(Mouse.X, Mouse.Y);
     if TabIndex >= 0 then
       TabControl.Hint.Text := Int2Str(TabIndex);
    //    TabControl.Hint.Text := TabControl.Pages[TabIndex].Hint.Text;
    end;

    begin
     Applet := NewForm(nil, '');
     TabControl := NewTabControl(Applet, [], [], nil, 0).SetAlign(caClient);
     TabControl.OnMouseMove := TOnMouse(MakeMethod(nil, @MouseMove));
     for i := 0 to 9 do
       TabControl.TC_Insert(i, Int2Str(i), 0).Hint.Text := Int2Str(i);
     Run(Applet);
    end.

  • Дмитрий К © (28.09.10 09:02) [4]
    program TabTest;

    uses
     Windows, Messages, KOL;

    var
     TabControl: PControl;
     i: Integer;
     PrevX, PrevY: Word;
     PrevIdx: Integer;

    procedure MouseMove(Dummy: Pointer; Sender: PControl; var Mouse: TMouseEventData);
    var
     TabIndex: Integer;
    begin
     TabIndex := TabControl.TC_TabAtPos(Mouse.X, Mouse.Y);
     if (TabIndex >= 0) then
     begin
       if ((abs(PrevX - Mouse.X) < 8) and (abs(PrevY - Mouse.y) < 8)) and (PrevIdx = TabIndex) then
         Exit;
     //   TabControl.Hint.Text := Int2Str(TabIndex);
       TabControl.Hint.Text := TabControl.Pages[TabIndex].Hint.Text;
       PrevX := Mouse.X;
       PrevY := Mouse.Y;
       PrevIdx := TabIndex;
     end;
    end;

    begin
     Applet := NewForm(nil, '');
     TabControl := NewTabControl(Applet, [], [], nil, 0).SetAlign(caClient);
     TabControl.OnMouseMove := TOnMouse(MakeMethod(nil, @MouseMove));
     for i := 0 to 9 do
       TabControl.TC_Insert(i, Int2Str(i), 0).Hint.Text := Int2Str(i);
     Run(Applet);
    end.

  • Jon © (29.09.10 00:11) [5]
    Thank you very much for the reply, it works well.

    Any suggestions for my other question?:


    > Jon ©   (26.09.10 18:16) [2]
    >
    > Also, how can I obtain which tab a control is placed on?
    > ...
    >  Sender.Parent.Caption := Sender.Caption; // Sender.Parent is incorrect?
  • Дмитрий К © (29.09.10 00:26) [6]
    function GetParentTabIdx(Control: PControl): Integer;
    var i: Integer;
    begin
     Result := -1;
     for i := 0 to TabControl.Count - 1 do
       if Control.Parent.Handle = TabControl.TC_pages[i].Handle then
       begin
         Result := i;
         break;
       end;
    end;

  • Jon © (29.09.10 01:59) [7]
    Thank you. Your logic is good, you make it look very easy.
  • Jon © (30.09.10 06:13) [8]
    One last question concerning TabControl: is it possible to remove the border from each page?
  • Дмитрий К © (30.09.10 21:49) [9]
    TabControl.Border := 0;

    ?
  • Jon © (01.10.10 01:55) [10]
    No, I wish that it was that easy!
    I have tried various methods:


    program TabTest;

    uses
     Windows, Messages, KOL;

    var
     TabControl, TabSheet: PControl;
     Rect: TRect;

    begin
     Applet := NewForm(nil, 'TabTest');
     Applet.Border := 0;
     Applet.Color := clRed;
    //---
     TabControl := NewTabcontrol(Applet, [], [], nil, 0).SetAlign(caClient);
     TabControl.Border := 0;
     TabSheet := TabControl.TC_Insert(0, 'TabBorderTest', -2);
     TabSheet.Border := 0;
    //---
     TabControl.Style := TabControl.Style and (not WS_DLGFRAME) and (not SS_SUNKEN);
     TabSheet.Style := TabSheet.Style and (not WS_DLGFRAME) and (not SS_SUNKEN);
    //---
     Rect := TabSheet.ClientRect;
     InflateRect(Rect, 4, 4);
    //  TabSheet.ClientRect := Rect; // Read-only property!
     Run(Applet);
    end.



    Any other ideas?
  • Дмитрий К © (01.10.10 02:07) [11]
    TabControl.Border := -4;

    ?
  • Jon © (01.10.10 03:41) [12]
    Yes, good thinking again. It's crude, but it does work. Thank you.
Есть новые Нет новых   [120347   +16][b:0][p:0.003]