Solved

bitmaps in lookupcombo drop down?

Posted on 2001-09-14
7
272 Views
Last Modified: 2013-12-03
Hi,

How do I display bitmaps in the drop down box of a TLookupCombo control?

As well, where can I get bitmaps of country flags(preferably 16x16 or 32x32).
 
Thanks,
Dion.
0
Comment
Question by:Diono
7 Comments
 
LVL 4

Expert Comment

by:fva
ID: 6482161
You could use a regular combo with OwnerDraw. Of course, the price will be a more complicated logic for filling and using the contents (no more DB awareness) but you'll get what you want (bitmaps). I think there's no easy way to derive/intercept regular behavior of the LookupCombo to obtain what you want.

As for the flag bitmaps, there are lots of sites with icons that probably contain the flags you want. Unfortunately I have no URL at hand but I'm sure you'll find someone to point you to some of them.

F.
0
 
LVL 1

Expert Comment

by:ntony
ID: 6482168
0
 
LVL 1

Expert Comment

by:malsoft
ID: 6482180
Diono,

Having looked at the code for the DBLookupCombo control, I'd agree with fva and say there's no really easy way of having an OwnerDraw variant of it. The control itself descends from TCustomControl, so it isn't even a true TComboBox (in fact the drop-down is actually a type of TListBox!).

You might have some luck in creating a descendant control and override the Paint method, but I don't see how you would access the items you'd need to draw, as these are declared as private.

As for the bitmaps, you could always have a look at http://www.flags.com
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Diono
ID: 6482657
Thanks guys, I have figured it out. I will still allocate the points to anybody who knows of an URL where I can get some decent bitmaps(ie maybe with some depth and a king of "flapping in the wind" effect) depicting country's of the world, especially Africa.

Thanks,
Dion.
0
 
LVL 4

Expert Comment

by:fva
ID: 6482680
If you find a solution, maybe you want to post it here so that we or any later readers of this thread (when it'll be a PAQ) can benefit from your experience.

F.
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 6483788
Try this example thats works fine.



procedure TForm1.FormCreate(Sender: TObject);
var
 Bmp: Tbitmap;
begin
        With Ttable.Create(nil) do
        try
          DabaseName :='XXXX';
          TableName:='Country.Db';
          Open;
            While not Eof do
            begin
            Bmp := TBitmap.Create;
              Try
                 Bmp.Assing(FieldByname('Flag'));
                 DbCombobox1.Items.AddObject(
                 FieldByName('country').AsString, Bmp);
               Except
               Bmp.Free;
               raise;
               end;
               Next
               end;
               finally
                 Free;
                 end;
end;




procedure TForm1.DBComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
        With control as TDbComboBox, canvas do
        begin
         Fillrect(Rect);
         StretchDraw(
          Bounds(Rect.Left +2, Rect.Top, ItemHeight, ItemHeight),
          Tbitmap(Items.Objects[index]));
         Textout(Rect.left + ItemHeight + 6, Rect.Top, Items[Index]);
         end;
end;
0
 

Accepted Solution

by:
grini earned 100 total points
ID: 6489613
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now