Search code examples
delphibitmapvclownerdrawn

Delphi TComboBox with fulltext search and bitmap (owner draw)


I use this code: How to make a combo box with fulltext search autocomplete support? to create custom TComboBox control with searching.

Everything was working fine but I decided to add bitmaps (pictures) into it using this method: ComboBox Simple with Bitmap

But when I added the second code I lost the searching functionality. To enable Owner drawing I added csOwnerDrawFixed style to control in constructor

constructor TComboBox.Create(AOwner: TComponent);
begin
  ...
  Style := csOwnerDrawFixed; ; << Added to enable owner draw
end;

How can I combine these two codes? The strange thing is when I run the project I can see the control redrawing correctly first time but then all data are lost and no drawing is done.


Solution

  • @Rohit Gupta: Actually it is pretty easy to merge that 2 codes: simply place 2nd code into 1st one and rename class :)

    I did this but the code is not working - painting the control causes freezing of software and I could not solve this issue that is why I asked for help.

    @Warren P: you are right, the better is to create custom control which handles everything.

    I created my own control which is basically TEdit with owner draw and TListBox with owner draw and TSpeedButton which works fine:

    Custom control with drawing

    I need to do some tweaking now and finished control will be available on my blog.

    If someone is interested then grab it later on http://unsigned.sk/blog/ (I will post comment here once finished).

    Thanks to all for ideas!