Solved

bitmaps in lookupcombo drop down?

Posted on 2001-09-14
7
274 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

895 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

20 Experts available now in Live!

Get 1:1 Help Now