蓝
蓝叶菱
Unregistered / Unconfirmed
GUEST, unregistred user!
原题:<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=3859264<br>以下是该控件我的模拟原代码:<br>放置一个TListBox,TMemo1,设置ListBox1的属性为:lbOwnerDrawFixed,<br>原代码如下:<br>unit uMain;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, ExtCtrls;<br><br>type<br> TFrmMain = class(TForm)<br> ListBox1: TListBox;<br> Memo1: TMemo;<br> procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;<br> Rect: TRect; State: TOwnerDrawState);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> PList:TStringList;<br> public<br> { Public declarations }<br> end;<br><br>var<br> FrmMain: TFrmMain;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TFrmMain.ListBox1DrawItem(Control: TWinControl; Index: Integer;<br> Rect: TRect; State: TOwnerDrawState);<br>var<br> i:integer;<br>begin<br> if Index div 2 =0 then<br> begin<br> ListBox1.Canvas.Font.Color:=clBlue;<br> ListBox1.Canvas.TextOut(Rect.Left,Rect.Top,PList.Strings[Index]);<br> end<br> else<br> begin<br> ListBox1.Canvas.Font.Color:=clgreen;<br> ListBox1.Canvas.TextOut(Rect.Left,Rect.Top,PList.Strings[Index]);<br> end;<br>end;<br><br>procedure TFrmMain.FormCreate(Sender: TObject);<br>var<br> i:integer;<br>begin<br> PList:=TStringList.Create;<br> for i:=0 to 20 do<br> begin<br> ListBox1.Items.Add('');<br> if i mod 2=0 then<br> PList.Add('时间:'+DateToStr(now)+' 有消息和信息传输!')<br> else<br> PList.Add('时间:'+DateToStr(now)+' 无消息!');<br> Memo1.Lines.Add(PList.Strings);<br> end;<br>end;<br><br>end.