?
Solved

bitmaps in lookupcombo drop down?

Posted on 2001-09-14
7
Medium Priority
?
284 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 300 total points
ID: 6489613
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

770 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