就是如何把Tbitmap加入到listview中去
解决方案 »
- 100分求关于用多线程读取PLC数据的实现方式????????
- 请教怎样实现图形的无缝平移?
- SkinEngine3.4.7此控件如何使用?
- 一个double型的变量,怎样才能变integer型的?
- 新手问题
- 【专题开发诚聘版主】 原因有几位版主任期将满
- 请教高手mailto中的正文怎样才可以长?
- 关于时间的问题
- 请问:《Delphi 5.X ADO/MTS/COM+高级程序设计篇》哪里有免费的电子书下载?李维的其他书呢?
- 简单?MS SQLSERVER 2000中用户自定义函数中的Execute问题!(含问题代码)
- 我是新手,问一个关于窗体的问题,delphi高手请进!
- 我写了一个小共享软件,8000多行,大家能不能进来帮我分析一下看有没有市场
在listview.ondrawitem里写代码。我也不是很熟,还没写出程序。
今天晚上装系统,耽误了时间。
自己画每个item,
属性设置:ListView1.ViewStyle:=vsList;ListView.OwnerDraw:=False;//这个不能为false
然后我在items里面有两个item,一个为Baby,一个为Hello;
然后她画图时就出发下列事件,画出了两幅大小不一的图。
你的要求是实现了,但讨厌在于这个东西,你画图时要自己定位。
所以要计算得很好,否则,画出来很丑。
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var Bitmap:TBitmap;
begin
if Item.Caption='Baby' then
begin
Bitmap:=TBitmap.Create;
Bitmap.LoadFromFile('1.bmp');
ListView1.Canvas.Draw(0,0,Bitmap);
Bitmap.Free;
end
else
begin
if Item.Caption='Hello' then
begin
Bitmap:=TBitmap.Create;
Bitmap.LoadFromFile('2.bmp');
ListView1.Canvas.Draw(0,100,Bitmap);
Bitmap.Free;
end;
end;
end;
半夜两点还在帮我的忙!
我现在用的d3,没有 listview1.canvas 属性,我有点难过了
不过我要装一下d5,看一看
如果功能实现,一定加分!
但是这样生成的图象无法执行我的双击事件
我的意思是在我的listview里面,用图象取代了caption
而且图象能够象item一样能够选择,响应双击事件
这个功能能实现吗?
我如下的程序以实现了点击事件。点击后触发onmousedown事件,判断其位置,做出
处理。你看如何?unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var x1,y1:integer;
implementation
{$R *.dfm}
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var Bitmap:TBitmap;
begin
Bitmap:=TBitmap.Create;
If Item.Caption='Hello' then
begin
Bitmap.LoadFromFile('1.bmp');
ListView1.Canvas.Draw(x1,y1,Bitmap);
Bitmap.FreeImage;
end
else
begin
Bitmap.LoadFromFile('2.bmp');
ListView1.Canvas.Draw(0,0,Bitmap);
x1:=0;//Bitmap.Width;
y1:=Bitmap.Height;
end;
DefaultDraw:=False;
end;
procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if y>y1 then
begin
ShowMessage('Hello');
end;
if y<y1 then
begin
ShowMessage('Baby');
end;
end;
end.
[email protected]
[email protected]