求购win2000事件查看器类似的ListView控件(100大洋)(100分)

  • 主题发起人 主题发起人 江远
  • 开始时间 开始时间

江远

Unregistered / Unconfirmed
GUEST, unregistred user!
性能指标:
1.单击列头自动排序,并显示是正向还是反向(类似Win2000);
2.支持RowSelect;
3.双击时可以确定是第几列.

 
2.支持RowSelect;
3.双击时可以确定是第几列.
这些标准控件也支持的。

1
像资源管理器那样对Subitem的内容进行排序。
最好自己来控制排序,如下所示:

function CustomSortProc( Item1, Item2 : TListItem; lParam : LongInt ) : Integer; stdcall;
begin
if lParam >= 0 then //lParam中保存的是SubItem的Index
begin
result := -CompareText(Item1.SubItems.Strings[lParam],
Item1.SubItems.Strings[lParam] );
end else
result := 0;
end;

在ListView的ColumnClick事件响应方法中输入
CustomSort(@CustomSortProc, Column.Index );


 
1、你的算法好象不能显示是正向还是反向(类似Win2000)?
2、标准控件好象不能知道双击的是第几列(若可以,请示例)
3、有些可排序LISTVIEW控件不支持ROWSELECT,所以我要加上此条
谢谢你的回答
 
ROWSELECT 只是一种界面,可以自画。
 
virtualtree控件,你的要求肯定可以满足!
速度也比较快,并且把TreeView和ListView融合
具体看它的帮助和原码
 
To Twos:
我试过了virtualtree,好象不行。谢谢!
 
我记得我师弟好象用VC搞出来过,我不想丢DELPHI的人。
 
你说的这些东东其实只用一个ListView就可以了,最多再加一个ImageList,现在没时间,
今晚搞一个,明早贴出来。
 
源代码如下,Delphi6+Win98上通过完全达到你的要求。
稍稍改一下就可以做成控件。
类似的控件在网上还有许多,这只是一个例子,用标准控件做的(ListView+ImageList)

Pas文件:
unit Unit1;

interface

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

type
TForm1 = class(TForm)
ListView1: TListView;
Button1: TButton;
ImageList1: TImageList;
procedure Button1Click(Sender: TObject);
procedure ListView1DblClick(Sender: TObject);
procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
private
{ Private declarations }
public
{ Public declarations }
end;

function CustomSortProc( Item1, Item2 : TListItem; lParam : LongInt ) : Integer; stdcall;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
List: TListItem;
I: Integer;
begin
ListView1.Items.Clear;
Randomize;
For i:=0 to 10 do
begin
List:=ListView1.Items.Add;
List.Caption:=IntToStr(Random(9));
List.SubItems.Add(IntToStr(Random(9)));
List.SubItems.Add(IntToStr(Random(9)));
List.SubItems.Add(IntToStr(Random(9)));
List.SubItems.Add(IntToStr(Random(9)));
List.ImageIndex:=-1;
List.Indent:=-1;
end;
end;

procedure TForm1.ListView1DblClick(Sender: TObject);
var
MousePosScreen,MousePosClient: TPoint;
//光标的屏幕坐标、光标的在LISTVIE上的坐标
i,j: integer;
CurrColumn: Integer;//被点击的Column
Find: Boolean;
begin
If ListView1.Selected<>nil then
begin
GetCursorPos(MousePosScreen);;
ListView1.GetItemAt(MousePosScreen.X,MousePosScreen.Y);
MousePosClient:=ListView1.ScreenToClient(MousePosScreen);
j:=ListView1.Column[0].Width;
Find:=False;
CurrColumn:=0;
i:=0;
while (not Find) and (i<ListView1.Columns.Count) do
begin
If j>=MousePosClient.X then
begin
Find:=True;
CurrColumn:=i+1;
end;
inc(i);
j:=j+ListView1.Column[i-1].Width;
end;
if Find then
ShowMessage(Format('第 %d 列',[CurrColumn]));
end;
end;

function CustomSortProc( Item1, Item2 : TListItem; lParam : LongInt ) : Integer; stdcall;
var
i: integer;
begin
if lParam >= 0 then //lParam中保存的是SubItem的Index
begin
If lParam=0 then
i := lstrcmp(PChar(Item1.Caption),PChar(Item2.Caption))
else
i := lstrcmp(PChar(Item1.SubItems.Strings[lParam-1]),PChar(Item2.SubItems.Strings[lParam-1]));
if Form1.ListView1.Column[lParam].Tag=0 then
result := -i
else
result := i;
end
else
result := 0;
end;

procedure TForm1.ListView1ColumnClick(Sender: TObject;
Column: TListColumn);
var
I: integer;
begin

ListView1.CustomSort(@CustomSortProc, Column.Index);
If Column.Tag=0 then
Column.Tag:=1
else
Column.Tag:=0;
For i:=0 to ListView1.Columns.Count-1 do
ListView1.Column.ImageIndex:=-1;
Column.ImageIndex:=Column.Tag;
end;

end.

DFM文件:
object Form1: TForm1
Left = 195
Top = 103
Width = 544
Height = 380
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ListView1: TListView
Left = 88
Top = 160
Width = 377
Height = 177
Columns = <
item
Caption = 'asasdf'
ImageIndex = 0
Width = 70
end
item
Width = 70
end
item
Width = 70
end
item
Width = 70
end
item
Width = 70
end>
Items.Data = {
4200000002000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000000008617364
6661736466FFFFFFFFFFFFFFFFFFFFFFFF000000000000000008617364667364
6166}
RowSelect = True
SmallImages = ImageList1
SortType = stText
TabOrder = 0
ViewStyle = vsReport
OnColumnClick = ListView1ColumnClick
OnDblClick = ListView1DblClick
end
object Button1: TButton
Left = 416
Top = 72
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
object ImageList1: TImageList
Left = 416
Top = 200
Bitmap = {
494C010102000400040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001001000000000000008
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000007B6F7B6F7B6F7B6F7B6F7B6F7B6F
7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F
7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F0000000000000000E07F00000000
000000000000000000000000000000000000000000000000000000000000E07F
0000000000000000000000000000000000000000F75EF75EF75EFF7F7B6F7B6F
7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F0000F75EF75EF75EFF7F7B6F7B6F
7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F0000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000FF7F
000000000000000000000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FF75EF75EF75EF75EF75EF75EF75E
F75EFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F00000000000000000000FF03FF03
FF03FF03FF03FF0300000000000000000000000000000000000000000000E07F
000000000000000000000000000000000000FF7FFF7FFF7FFF7FFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F0000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000FF7F
0000FF7F00000000000000000000000000000000F75EF75EF75EFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F0000F75EF75EF75EFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F000000000000000000000000E07F
FF7FE07FFF7FE07F00000000000000000000000000000000000000000000E07F
0000E07F0000E07F00000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FF75EF75EF75EF75EF75EF75EF75E
F75EFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F00000000000000000000E07FFF7F
E07FFF7FE07FFF7FE07F0000000000000000000000000000000000000000FF7F
0000FF7F0000FF7F00000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75E00000000000000000000FF7FE07F
FF7FE07FFF7F0000FF7F00000000000000000000000000000000E07F0000E07F
FF7FE07FFF7FE07F00000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75E00000000000000000000E07FFF7F
E07FFF7FE07F0000E07F00000000000000000000000000000000FF7F0000FF7F
E07FFF7FE07FFF7F00000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75E00000000000000000000FF7F0000
FF7F0000FF7F0000000000000000000000000000000000000000E07FFF7FE07F
FF7FE07FFF7FE07F00000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75E00000000000000000000E07F0000
E07F0000E07F00000000000000000000000000000000000000000000E07FFF7F
E07FFF7FE07F000000000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75EF75E
F75EF75EF75EF75EF75EF75EF75EF75EF75E0000000000000000000000000000
FF7F0000FF7F0000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000F75EF75EF75EF75EF75EF75EF75E
F75EFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FF75EF75EF75EF75EF75EF75EF75E
F75EFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F0000000000000000000000000000
00000000E07F00000000000000000000000000000000000000000000FF03FF03
FF03FF03FF03FF0300000000000000000000FF7FFF7FFF7FFF7FFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F0000000000000000000000000000
00000000FF7F0000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FF7FFF7FFF7FFF7FFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F
FF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7FFF7F0000000000000000000000000000
00000000E07F0000000000000000000000000000000000000000000000000000
0000000000000000E07F00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000007B6F7B6F7B6F7B6F7B6F7B6F
7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F
7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F7B6F424D3E000000000000003E000000
2800000040000000100000000100010000000000800000000000000000000000
000000000000000000000000FFFFFF00E00FFDFFFFFFFFFFE00FF8FFFFFFFFFF
E00FF8FF00000000F00FF87F00000000F00FF81FFFFFFFFFF80FF80FFFFFFFFF
F007F00F0000E0FFF007E00F00000000F007E00FFFFFFFFFF00FE00FFFFFFFFF
F01FF01F00000000F81FF00F00000000FE1FF00FFFFFFFFFFF1FF007561F3800
FF1FF007107B2000FFBFF00700000000}
end
end

 
谢谢LeonSu,我试一试,很快回来.
 
接受答案了,谢市长LeonSu,你是高手
 

Similar threads

回复
0
查看
1K
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
851
DelphiTeacher的专栏
D
后退
顶部