Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to draw a bitmap between the checkbox and the label in a TCheckListBox Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
27-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
176
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to draw a bitmap between the checkbox and the label in a TCheckListBox

Answer:

This should do the trick. It is also possible to place a bitmap in the middle, i.e. 
The checkbox, then some text, the graphic, then more text, on the same line. The 
Checklistbox style must be set to lbOwnerDrawVariable for this to work.

1   procedure TForm1.Button2Click(Sender: TObject);
2   begin
3     {Bit1 is called from a resource file}
4     CheckListBox1.Items.AddObject('Test this bitmap', Bit1);
5   end;
6   
7   procedure TForm1.CheckListBox1DrawItem(Control: TWinControl; Index: Integer;
8     Rect: TRect; State: TOwnerDrawState);
9   var
10    Bitmap: TBitmap;
11    Offset: Integer;
12  begin
13    Offset := 12;
14    with (Control as TCheckListBox).Canvas do
15    begin
16      FillRect(Rect);
17      Bitmap := TBitmap(CheckListBox1.Items.Objects[Index]);
18      if Bitmap <> nil then
19      begin
20        BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width, Bitmap.Height),
21          Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), clRed);
22        Offset := Bitmap.width + 8;
23      end;
24      TextOut(Rect.Left + Offset, Rect.Top, CheckListbox1.Items[Index])
25    end;
26  end;
27  
28  procedure TForm1.CheckListBox1KeyUp(Sender: TObject; var Key: Word; Shift: 
29  TShiftState);
30  begin
31    height := 16;
32  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC