奇怪的CustomSort

Sephil 2004-06-12 08:45:40
今天用Delphi写程序的时候发现一个有趣的事
当ListView的Items是以A-Z为Caption
CustomSort的时候只要传一个TLVCompare,而TLVCompare都不用写实现
可程序居然会自动排序,XIXI
...全文
52 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sephil 2004-06-12
  • 打赏
  • 举报
回复
upup
Sephil 2004-06-12
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;

type
TForm1 = class(TForm)
ListView1: TListView;
procedure FormCreate(Sender: TObject);
procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
I: Char;
begin
for I := 'a' to 'z' do
ListView1.Items.Add.Caption := I;
for I := 'A' to 'Z' do
ListView1.Items.Add.Caption := I;
end;

function SortProc(lParam1, lParam2, lParamSort: Integer): Integer stdcall;
begin
end;

procedure TForm1.ListView1ColumnClick(Sender: TObject;
Column: TListColumn);
begin
ListView1.CustomSort(SortProc, 0);
end;

end.
Sephil 2004-06-12
  • 打赏
  • 举报
回复
顶一下

552

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 茶馆
社区管理员
  • 茶馆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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