Solved

bitmaps in lookupcombo drop down?

Posted on 2001-09-14
7
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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