Recent

Author Topic: TComboBoxEx and TCheckComboBox  (Read 13198 times)

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
TComboBoxEx and TCheckComboBox
« on: September 11, 2014, 01:39:40 am »
Hi,

two new components derived from TCustomComboBox can be downloaded from here:
http://bugs.freepascal.org/view.php?id=26515 (download comboex3.zip)

TComboBoxEx is known from Delphi7, it is combo with images. Property Items: TStrings is covered and ItemsEx: TCollection is used instead.
Contrary to Delphi, Lazarus implementation is read-only due to technical reasons (we need csOwnerDrawFixed).

TCheckComboBox is combo with check-boxes. Each item can be unchecked/grayed/checked and disabled/enabled.

Both components are painted via Themes, read-only and support right-to-left BiDiMode.

There are some limitaitons so please read readme.txt before you start to use it.

Enjoy!
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TComboBoxEx and TCheckComboBox
« Reply #1 on: September 11, 2014, 02:31:01 am »
Using comboex3 on Windows.

My first test:
Created a TComboBoxEx at run-time and added a few items using AddItem, as soon as I touched it, it gave me "List index (0) out of bounds." error message. Test code:
Code: [Select]
uses
..., comboex;

procedure TForm1.Button1Click(Sender: TObject);
var
  C1:TComboBox;
  C2:TComboBoxEx;

  procedure Test1(C: TCustomComboBox; vTop: integer);
  var
    i:integer;
  begin
    with C do
    begin
      Left := 10;
      Top := vTop;
      Parent := Self;
      for i := 1 to 10 do
        if C is TComboBoxEx then
          (C as TComboBoxEx).AddItem(Format('AddItem %d',[i]), TObject.Create)
        else
          Items.Add(Format('Add %d',[i]));
    end;
  end;

begin
  C1:=TComboBox.Create(Self);
  Test1(C1, 100);

  C2:=TComboBoxEx.Create(Self);
  Test1(C2, 200);
end;

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: TComboBoxEx and TCheckComboBox
« Reply #2 on: September 11, 2014, 01:33:31 pm »
Same here @Blaazen win7 64bit
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx and TCheckComboBox
« Reply #3 on: September 11, 2014, 02:15:33 pm »
This is not really a bug since correct line is:
Code: [Select]
(C as TComboBoxEx).ItemsEx.Add(Format('AddItem %d',[i]))
But I can override or reintroduce TCustomComboBox.AddItem(); and I am going to do it.

Method AddItem(); is valid for TCheckComboBox.

Note that TCheckComboBox and TComboBoxEx are different and they are implemented differently. The only thing is that they are both derived from TCustomComboBox and they are in the same unit.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

wp

  • Hero Member
  • *****
  • Posts: 12920
Re: TComboBoxEx and TCheckComboBox
« Reply #4 on: September 11, 2014, 02:37:16 pm »
Just tested these new components. Nice!

An idea for an alternative operation mode of the checkedCombo: Shouldn't the text displayed in the non-dropped down field be shown as a combination of all checked items? Currently the combo displays only the most-recently selected item. Say, if the combobox contains the items "Asia", "America", "Asia", "Australia", "Europe", and the first two are checked, then the "result" in the always visible line should be "Asia;America". When nothing is checked the field should be empty, or show a user-defined text such as "nothing selected"

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1263
Re: TComboBoxEx and TCheckComboBox
« Reply #5 on: September 11, 2014, 02:42:43 pm »
Nicely done.  I for one am hoping these get incorporated in the standard controls and shipped with Lazarus.
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TComboBoxEx and TCheckComboBox
« Reply #6 on: September 11, 2014, 02:50:52 pm »
Check the attached image. Using TCheckComboBox, changing width to 200. How to reproduce:
1-Open the list
2-Choose one item
3-Click on the edit anywhere between the check box and the drop-down button
4-Move the form.

Here is the code I used:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  C1: TComboBox;
  C2: TCheckComboBox;

  procedure Test1(C: TCustomComboBox; vTop: integer);
  var
    i:integer;
  begin
    with C do
    begin
      Left := 10;
      Top := vTop;
      Width := 200;
      Parent := Self;
      for i := 1 to 10 do
        if (C is TCheckComboBox) then
          (C as TCheckComboBox).AddItem(Format('AddItem %d',[i]), cbChecked)
        else
          Items.Add(Format('Add %d',[i]));
    end;
  end;

begin
  C1:=TComboBox.Create(Self);
  Test1(C1, 100);

  C2:=TCheckComboBox.Create(Self);
  Test1(C2, 200);
end;

Notice that I use an old version of Lazarus 2.7.1 on Windows XP.

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx and TCheckComboBox
« Reply #7 on: September 11, 2014, 03:19:32 pm »
I can reproduce but the same is with normal TComboBox  8), so it is inherited behaviour and it should go to bugtracker.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TComboBoxEx and TCheckComboBox
« Reply #8 on: September 11, 2014, 04:17:55 pm »
I can reproduce but the same is with normal TComboBox
I could not reproduce it with the normal TComboBox. I tried adding:
Code: [Select]
  C1.Style:=csOwnerDrawFixed;
  C1.ReadOnly:=True;
to the previous code to imitate your control, but that did not give the same behavior.  :-\

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx and TCheckComboBox
« Reply #9 on: September 11, 2014, 06:34:45 pm »
Quote
I could not reproduce it with the normal TComboBox.
I have only Wine, not a real Windows. I can reproduce with normal TComboBox and I can reproduce it with Delphi7 too.
It's easy.
1) Run demo
2) Open combo
3) Drag Form title-bar and move it

What happens with normal combo when you try to move form?
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TComboBoxEx and TCheckComboBox
« Reply #10 on: September 11, 2014, 06:48:56 pm »
closes the combo box before moving, its a wine side effect.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx and TCheckComboBox
« Reply #11 on: September 11, 2014, 07:11:46 pm »
Quote
closes the combo box before moving, its a wine side effect.
:)

@ engkin
Is there different behavior between TComboBoxEx and TCheckComboBox ?

Thanks.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TComboBoxEx and TCheckComboBox
« Reply #12 on: September 11, 2014, 07:26:01 pm »
Is there different behavior between TComboBoxEx and TCheckComboBox ?
Yes, the problem is only in TCheckComboBox.

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBoxEx and TCheckComboBox
« Reply #13 on: September 11, 2014, 07:38:15 pm »
Thanks, but I will hardly repair it because I have only Wine (where this bug is by design) and also, I cannot see anything wrong it the code.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TComboBoxEx and TCheckComboBox
« Reply #14 on: September 11, 2014, 07:48:48 pm »
Yes, I understand. It is not just moving the form, that was just an example. What happens that the list gets stuck and does not close. If you see previous image I posted earlier, you'll notice that the list items were highlighted.

 

TinyPortal © 2005-2018