Solved

bitmaps in lookupcombo drop down?

Posted on 2001-09-14
7
283 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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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