Конференция "KOL" » Toolbar issue with KOL v3.00
 
  • Jon © (12.10.10 03:47) [0]
    With KOL v2.94++ the code below works correctly, but with v3.00 the toolbar is drawn incorrectly when the button is clicked.


    program Test;

    uses
     Windows, KOL;

    var
     ToolBar: PControl;

    procedure ButtonClick(Dummy: Pointer; Sender: PControl);
    begin
     ToolBar.TBAddButtons(['Add1', 'Add2'], [-2, -2]);
    end;

    begin
     Applet := NewForm(nil, 'Toolbar');
     Toolbar := NewToolbar(Applet, caTop, [], hBitmap(-1), [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-'], [1, 2, 3, 4, 5, 6, 7, 8]);
     with NewButton(Applet, 'Add').CenterOnParent^ do
       OnClick := TOnEvent(MakeMethod(nil, @ButtonClick));
     Run(Applet);
    end.



    What can be done to fix compatibility?
  • Vladimir Kladov © (12.10.10 16:22) [1]

    program Test;

    uses
    Windows, KOL;

    var
    ToolBar: PControl;

    procedure ButtonClick(Dummy: Pointer; Sender: PControl);
    begin
    ToolBar.TBAddButtons(['Add1', 'Add2'], [-2, -2]);
    end;

    begin
    Applet := NewForm(nil, 'Toolbar').SetSize( 800, 200 ).SetPosition( 300, 100 );
    Toolbar := NewToolbar(Applet, caTop, [], hBitmap(-1), [ ], [ ] );
    Toolbar.TBAutoSizeButtons := TRUE;
    Toolbar.TBAddButtons( [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-'],
                          [1, 2, 3, 4, 5, 6, 7, 8]);
    with NewButton(Applet, 'Add').CenterOnParent^ do
      OnClick := TOnEvent(MakeMethod(nil, @ButtonClick));
    Run(Applet);
    end.


    I am sorry that it is not a default behavior, may be it is better to set TBAutoSize to TRUE by default and to use assigning to it FALSE to get same width buttons. At least this can be controlled with conditionals as usual in such cases.
  • Jon © (12.10.10 16:37) [2]
    Thank you for the answer - I was puzzled why it was different.

    On a similar theme:

    Kol simple Coolbar Control - http://www.thaddy.co.uk/kolcoolbar.zip

    I changed erroneous code from:


     Result := PCoolbar(_NewControl(AParent, REBARCLASSNAME, Style, False, @LabelActions));
     PHack(Result).fSizeRedraw := True;



    to this for KOL v3:


     Result := PCoolbar(_NewControl(AParent, REBARCLASSNAME, Style, False, LabelActions_Packed));
     Result.fFlagsG1 := Result.fFlagsG1 + [G1_SizeRedraw, G1_IsStaticControl];



    Is this correct?
  • Vladimir Kladov © (12.10.10 16:58) [3]
    Why did you add G1_IsStaticControl ? I don't see an assigning fIsStaticControl in a portion of code #1. And, it was not erroneous, it was correct (may be) before 3.00. More correct include changes into {$IFDEF USE_FLAGS} ... and leave elder code in the {$ELSE} branch. At least for a while. Some people never switch to newer versions for years. I understand them very good.
  • Jon © (12.10.10 17:21) [4]
    Thank you for clearing up my confusion.
  • Jon © (19.10.10 00:00) [5]
    I find that TBButtonsMinWidth does not work as in the following example:


    program Test;

    uses KOL;

    var ToolBar: PControl;

    begin
     Applet := NewForm(nil, 'Toolbar');
     Toolbar := NewToolbar(Applet, caTop, [], 0, [], []);
     Toolbar.TBAutoSizeButtons := False;
     ToolBar.TBButtonsMinWidth := 100;
     Toolbar.TBAddButtons(['1', '2', '3', '4', '5'], []);
     Run(Applet);
    end.

  • Vladimir Kladov © (19.10.10 06:14) [6]
    Assign ToolBar.TBButtonsMaxWidth := 100; too.
  • Jon © (19.10.10 12:06) [7]
    OK, thank you. But now I found problem with blank labels:


    program Test;

    uses KOL;

    var ToolBar: PControl;

    begin
     Applet := NewForm(nil, 'Toolbar');
     Toolbar := NewToolbar(Applet, caTop, [], 0, [], []);
     Toolbar.TBAutoSizeButtons := False;
     ToolBar.TBButtonsMinWidth := 100;
     ToolBar.TBButtonsMaxWidth := 100;
     Toolbar.TBAddButtons([' ', ' ', ' ', ' ', ' '], []);  // incorrect
    //  Toolbar.TBAddButtons(['1', ' ', ' ', ' ', ' '], []);  // correct
     Run(Applet);
    end.

  • Vladimir Kladov © (19.10.10 13:47) [8]
    Try two spaces in (e.g.) the first label.
  • Jon © (19.10.10 21:37) [9]
    That works - thanks.
  • thaddy © (19.11.10 00:58) [10]
    or an obsolete '' as an extra unused parameter at the end. Somehow this was documented somewhere.... ;-)

    Toolbar.TBAddButtons([' ', ' ', ' ', ' ', ' ',''], []);
    //------------------------------------^

  • thaddy © (19.11.10 00:59) [11]
    mm. formatting went wrong, it's the last entry: empty char.
  • Jon © (19.11.10 21:24) [12]

    > or an obsolete '' as an extra unused parameter at the end.
    > Somehow this was documented somewhere.... ;-)
    >
    > Toolbar.TBAddButtons([' ', ' ', ' ', ' ', ' ',''], []);


    Thanks Thaddy, but I just tried and it adds another toolbar button.
    I believe that you may be thinking about menu items and unused '' at the end.
    Vladimir's solution of using an additional space character works fine.
 
Конференция "KOL" » Toolbar issue with KOL v3.00
Есть новые Нет новых   [120346   +14][b:0][p:0.003]