Delphi控制ListBox控件在顯示文字時折行顯示內容,左右兩個ListBox中,在右側ListBox中粘貼入數據,點擊“復制”後,左側的ListBox中會顯示相應內容,你點擊一下任意內容,會發現Listbox會自動將某一段文字折行顯示,以保持原有文字的排版風格,這是個不錯的小技巧。
01
unit
Unit1;
02
interface
03
uses
04
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
05
Dialogs, StdCtrls;
06
type
07
TForm1 =
class
(TForm)
08
ListBox1: TListBox;
09
Memo1: TMemo;
10
Button1: TButton;
11
procedure
ListBox1MeasureItem(Control: TWinControl; Index:
Integer
;
12
var
Height:
);
13
Button1Click(Sender: TObject);
14
ListBox1DrawItem(Control: TWinControl; Index:
15
Rect: TRect; State: TOwnerDrawState);
16
private
17
{ Private declarations }
18
public
19
{ Public declarations }
20
end
21
22
Form1: TForm1;
23
implementation
24
{$R *.dfm}
25
TForm1
.
26
27
28
lpstr:
PChar
29
c,h:
integer
30
tc:TRect;
31
begin
32
with
Control
as
TListBox
do
33
34
c:=length(items[index]);
35
lpstr:=
(Items[index]);
36
tc:=clIEntrect;
37
h:=drawtext(Canvas
Handle,lpstr,c,tc,DT_CALCRECT
or
DT_WordBREAK);
38
39
Height:=h+
4
40
41
42
43
listbox1
Items
Assign(memo1
Lines);
44
45
46
47
48
49
c:
50
51
52
53
Canvas
FillRect(Rect);
54
55
56
drawtext(Canvas
Handle,lpstr,c,Rect,DT_WordBREAK);
57
58
59
本例效果圖: 代碼文件:unit Unit1;inter
本例效果圖:代碼文件:unit Unit1;i
TDXImageList.Items 中的每個 TPict
//程序代碼: unit Unit1; interfa
本例效果圖: 代碼文件:unit Unit1;inte
SetBlendTriangularShape