如何用listview实现Tbitmap的排列?

asgq 2001-08-06 01:54:45
我的意思是不要caption 而用bitmap来实现
...全文
139 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
asgq 2001-08-10
  • 打赏
  • 举报
回复
希望能和朋友们多交流!
asgq@0412.net
asgq@sina.com.cn
asgq 2001-08-08
  • 打赏
  • 举报
回复
好啊,写代码的话是能够实现啊
就是定位麻烦,多谢ch81捧场!
还有其他朋友!不知还有没有更好的方法,明天结贴!
asgq 2001-08-07
  • 打赏
  • 举报
回复
d5能够实现,
但是这样生成的图象无法执行我的双击事件
我的意思是在我的listview里面,用图象取代了caption
而且图象能够象item一样能够选择,响应双击事件
这个功能能实现吗?
guqiang 2001-08-07
  • 打赏
  • 举报
回复
多谢ch81:
半夜两点还在帮我的忙!
我现在用的d3,没有 listview1.canvas 属性,我有点难过了
不过我要装一下d5,看一看
如果功能实现,一定加分!
ch81 2001-08-07
  • 打赏
  • 举报
回复
asgq(强子) 
我如下的程序以实现了点击事件。点击后触发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.
ch81 2001-08-07
  • 打赏
  • 举报
回复
终于实现了!!
今天晚上装系统,耽误了时间。
自己画每个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;
wolfAone 2001-08-06
  • 打赏
  • 举报
回复
能不能具体,再具体一点呢?
ch81 2001-08-06
  • 打赏
  • 举报
回复
要符合你的要求,只能自己画。
在listview.ondrawitem里写代码。我也不是很熟,还没写出程序。
szkingrose 2001-08-06
  • 打赏
  • 举报
回复
设定 Tlistitem的tag值为你的所想付给的值,不要说不行,我试过的
asgq 2001-08-06
  • 打赏
  • 举报
回复
up
asgq 2001-08-06
  • 打赏
  • 举报
回复
我非常急,请朋友们多帮忙
asgq 2001-08-06
  • 打赏
  • 举报
回复
imagelist是固定大小的,我的意思是用自定义的位图
chechy 2001-08-06
  • 打赏
  • 举报
回复
用ImageList啊。ListView有LargeImages、SmallImages可以与ImageList关联。
asgq 2001-08-06
  • 打赏
  • 举报
回复
就是如何把Tbitmap加入到listview中去

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧