扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:陈立平 来源:yesky 2007年11月1日
关键字:
procedure TForm1.ListBox4MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); begin file://控制图片的高度 Height := 59; end; |
procedure TForm1.ListBox4DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var ABmp: TBitmap; begin try ABmp := TBitmap.Create; ImageList2.GetBitmap(Index, ABmp); ListBox4.Canvas.FillRect(Rect); ListBox4.Canvas.Draw(Rect.Left, Rect.Top, ABmp); finally ABmp.Free; end; end; |
procedure TForm1.ListBox5MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); begin file://控制图片的高度 Height := 59; end; |
procedure TForm1.ListBox5DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var file://图片文件名 Fn: string; ABmp: TBitmap; begin try ABmp := TBitmap.Create; Fn := ListBox5.Items[Index]; ABmp.LoadFromFile(ListBox5.Items[Index]); Dec(Rect.Bottom); ListBox5.Canvas.FillRect(Rect); ListBox5.Canvas.StretchDraw(Rect, ABmp); finally ABmp.Free; end; end; |
var sr: TSearchRec; Dir: string; begin Dir := ''; file://选择目录对话框,需要在Uses中加入对FileCtrl单元的引用声明 if SelectDirectory('选择图片目录', '', Dir) then begin ListBox5.Items.Clear; file://搜索该目录下的所有bmp文件 if FindFirst(Dir + '\*.bmp', faReadOnly, sr) = 0 then begin ListBox5.Items.Add(Dir + '\' + Sr.Name); while FindNext(sr) = 0 do begin ListBox5.Items.Add(Dir + '\' + Sr.Name); end; FindClose(sr); end; end; end; |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。