Конференция "KOL" » TabControl Pages
 
  • Jon © (19.01.08 19:10) [0]
    Is it possible to dynamically show / hide individual pages in Tab Control?
  • Jon © (22.01.08 02:13) [1]
    Ah, I found a solution:
    Remove:
    RemovedPage := TabControl.TC_Remove(0);


    Insert:
    TabControl.TC_InsertControl(0,'Tab',0,RemovedPage);



    Now a question on keyboard use:

    How can I enable CTRL+TAB and SHIFT+CTRL+TAB to navigate tabs (just like VCL)?
    Or do I have to code my own routine?
    I thought that Tabulate would support this.
  • Dimaxx © (22.01.08 13:57) [2]
    By default use Ctrl+PgDn & Ctrl+PgUp to navigate tabs.
  • Jon © (22.01.08 14:56) [3]
    I have tried but it does not work.
    Is there an option to enable it?
    I have tried with KOL and KOL+MCK.
  • Dimaxx © (23.01.08 10:06) [4]
    Maybe Tabulate or TabulateEx?
  • Jon © (23.01.08 11:49) [5]
    No, neither of those work.
    Any other suggestions?
  • Dimaxx © (23.01.08 21:58) [6]
    I have no idea... :(
  • Jon © (24.01.08 04:19) [7]
    Now trying to modify Tabulate2Control in KOL.PAS
    Problem is that I break standard tabulate functions
    The TAB key cannot be processed with key preview enabled
    My attempts at sub-classing TabControl also unsuccessful
    Is the keyboard handling for this control a bug or by design?
  • Jon © (27.01.08 22:10) [8]
    Modifying KOL.PAS did not help.
    I am willing to try suggestions from this forum.
  • Jon © (29.01.08 03:16) [9]
    Bug with TabControl:

    >     function TC_DisplayRect: TRect;
    >     {* |<#tabcontrol>
    >        Returns rectangle, occupied by a page rather then tab. }

    Result.Top and Result.Bottom include height of tab too.
  • имя (08.08.08 16:13) [10]
    Удалено модератором
  • Jon © (08.11.08 16:08) [11]

    > How can I enable CTRL+TAB and SHIFT+CTRL+TAB to navigate tabs (just like VCL)?

    I am still looking for a solution if anyone has suggestions.
  • Jon © (18.05.09 16:52) [12]
    > How can I enable CTRL+TAB and SHIFT+CTRL+TAB to navigate tabs (just like VCL)?


    Can anyone please provide any help? Multi-tabbed applications are common nowadays and I would love to have this feature added to KOL.
  • Дмитрий К © (18.05.09 18:22) [13]
    program Project1;

    uses
     Windows, Messages, KOL;
    type
     PForm1 = ^TForm1;
     TForm1 = object(TObj)
     private
       Form, TC: PControl;
       function FormMessage(var Msg: TMsg; var Rslt: Integer): Boolean;
       procedure SwitchTab(Down: Boolean);
     end;

    var
     Form1: PForm1;
     KBHook: HHook;
    const
     WM_SWITCHTAB = WM_USER + $400;

    function NewForm1(AParent: PControl): PForm1;
    var i: Integer;
    begin
     New(Result, Create);
     with Result^ do
     begin
       Form := NewForm(AParent, 'Form1');
       Form.Add2AutoFree(Result);
       TC := NEwTabControl(Form, ['0','1','2','3','4'], [], nil, 0).SetAlign(caCLient);
       for i := 0 to 4 do
       begin
         NewLabel(TC.TC_Pages[i], 'Label '+ int2str(i));
       end;
       Form.OnMessage := FormMessage;
     end;
    end;

    function TForm1.FormMessage(var Msg: TMsg; var Rslt: Integer): Boolean;
    begin
     Result := False;
     case Msg.message of
       WM_SWITCHTAB: SwitchTab(Boolean(Msg.wParam));
     end;
    end;

    procedure TForm1.SwitchTab(Down: Boolean);
    begin
     if Down then
     begin
       if TC.CurIndex = 0 then
         TC.CurIndex := TC.Count - 1
       else
         TC.CurIndex := TC.CurIndex - 1
     end
     else
       if TC.CurIndex = TC.Count - 1 then
         TC.CurIndex := 0
       else
         TC.CurIndex := TC.CurIndex + 1

    end;

    function KeybProc(Code: Integer; wParam, lParam: Integer): Integer; stdcall;
    begin
     if Code >= 0 then
     begin
       if (wParam = VK_TAB) and (lParam and $80000000 = 0) then
       begin
         if GetKeyState(VK_CONTROL) and $8000 = $8000 then
           Form1.Form.Perform(WM_SWITCHTAB, (GetKeyState(VK_SHIFT) and $8000) shr 15, 0);
       end;
     end;
     Result := CallNextHookEx(KBHook, Code, wParam, lParam);
    end;

    begin
     Form1 := NewForm1(nil);
     Applet := Form1.Form;
     KBHook := SetWindowsHookEx(WH_KEYBOARD, KeybProc, 0, GetCurrentThreadID);
     if KBHook = 0 then
       MsgOK(SysErrorMessage(GetLastError));

     Run(Applet);
     UnhookWindowsHookEx(KBHook);
    end.

  • Jon © (18.05.09 19:55) [14]
    Ah, hooks! Thank you very much Dmitry, I really appreciate the help.
  • имя (17.07.09 09:30) [15]
    Удалено модератором
  • имя (17.07.09 09:30) [16]
    Удалено модератором
Есть новые Нет новых   [134431   +10][b:0][p:0.002]