MEGA Search
20.3 Million


Sign Up
From: Michael Murray  
Subject: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 6-Feb-2004 at 11:38:58 PST
I am using the TShellListView component in Delphi 7. The ViewStyle property
is vsReport. When the user clicks on the column header I want to be able to
sort that column. By default, clicking the column header does nothing. I
tried using the custom sort method in the column click event, but the
callback function to sort never gets fired.

Does anyone know of a way to sort a TShellListView in report mode, any help
would be appreciated. Thanks Mike



From: Michael Murray  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 11-Feb-2004 at 21:41:58 PST
Hey Jim, Thanks it works. Mike
"Jim Kueneman"  wrote in message
news:40299173@newsgroups.borland.com...
> Michael Murray wrote:
>
> > Not looking for something real industrial strength, just something
> > that will mimic explorer to show folders and files with appropiate
> > information if in report mode. I have seen your web page and control
> > before, it is nice, but I think a little over the top for what I
> > need. I would like to sort it, I have seen posts like this before,
> > and no one has been able to say definitively how to sort a
> > TShellListView, I would be willing to modify their source if I had
>
>
> Ok, easy.
>
>
> Modify ShellCtrls.pas:
>
> TCustomShellListView = class(TCustomListView, IShellCommandVerb)
> ...
> public
> ...
>   property FolderList: TList read FFolders;  << ADD THIS
> ...
> end;
>
>
> unit Unit1;
>
> interface
>
> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
>   ComCtrls, ShellCtrls;
>
> type
>   TForm1 = class(TForm)
>     ShellListView1: TShellListView;
>     procedure ShellListView1ColumnClick(Sender: TObject;
>       Column: TListColumn);
>   private
>     { Private declarations }
>   public
>    { Public declarations }
>
>   end;
>
>
> var
>   Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> var
>   SortColumn: Integer;
>
> function ShellCompare(Item1, Item2: Pointer): Integer;
> begin
>     Result := Smallint(
>                   TShellFolder(Item1).ParentShellFolder.CompareIDs(
>                   SortColumn,
>                   TShellFolder(Item1).RelativeID,
>                   TShellFolder(Item2).RelativeID)
>               );
> end;
>
>
>
> procedure TForm1.ShellListView1ColumnClick(Sender: TObject;
>   Column: TListColumn);
> begin
>   SortColumn := Column.Index;
>   ShellListView1.FolderList.Sort(ShellCompare);
>   ShellListView1.Invalidate;
> end;
>
> end.
>
> -- 
> Jim
>
> Posted with XanaNews 1.16.1.7



From: Michael Murray  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 11-Feb-2004 at 10:20:16 PST
Thanks for responding Jim, I will try it out and let you know my results.
Mike

"Jim Kueneman"  wrote in message
news:40299173@newsgroups.borland.com...
> Michael Murray wrote:
>
> > Not looking for something real industrial strength, just something
> > that will mimic explorer to show folders and files with appropiate
> > information if in report mode. I have seen your web page and control
> > before, it is nice, but I think a little over the top for what I
> > need. I would like to sort it, I have seen posts like this before,
> > and no one has been able to say definitively how to sort a
> > TShellListView, I would be willing to modify their source if I had
>
>
> Ok, easy.
>
>
> Modify ShellCtrls.pas:
>
> TCustomShellListView = class(TCustomListView, IShellCommandVerb)
> ...
> public
> ...
>   property FolderList: TList read FFolders;  << ADD THIS
> ...
> end;
>
>
> unit Unit1;
>
> interface
>
> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
>   ComCtrls, ShellCtrls;
>
> type
>   TForm1 = class(TForm)
>     ShellListView1: TShellListView;
>     procedure ShellListView1ColumnClick(Sender: TObject;
>       Column: TListColumn);
>   private
>     { Private declarations }
>   public
>    { Public declarations }
>
>   end;
>
>
> var
>   Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> var
>   SortColumn: Integer;
>
> function ShellCompare(Item1, Item2: Pointer): Integer;
> begin
>     Result := Smallint(
>                   TShellFolder(Item1).ParentShellFolder.CompareIDs(
>                   SortColumn,
>                   TShellFolder(Item1).RelativeID,
>                   TShellFolder(Item2).RelativeID)
>               );
> end;
>
>
>
> procedure TForm1.ShellListView1ColumnClick(Sender: TObject;
>   Column: TListColumn);
> begin
>   SortColumn := Column.Index;
>   ShellListView1.FolderList.Sort(ShellCompare);
>   ShellListView1.Invalidate;
> end;
>
> end.
>
> --
> Jim
>
> Posted with XanaNews 1.16.1.7



From: Jim Kueneman  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 10-Feb-2004 at 18:20:35 PST
Michael Murray wrote:

> Not looking for something real industrial strength, just something
> that will mimic explorer to show folders and files with appropiate
> information if in report mode. I have seen your web page and control
> before, it is nice, but I think a little over the top for what I
> need. I would like to sort it, I have seen posts like this before,
> and no one has been able to say definitively how to sort a
> TShellListView, I would be willing to modify their source if I had


Ok, easy.


Modify ShellCtrls.pas:

TCustomShellListView = class(TCustomListView, IShellCommandVerb)
....
public
....
  property FolderList: TList read FFolders;  << ADD THIS
....
end;


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  ComCtrls, ShellCtrls;

type
  TForm1 = class(TForm)
    ShellListView1: TShellListView;
    procedure ShellListView1ColumnClick(Sender: TObject;
      Column: TListColumn);
  private
    { Private declarations }
  public
   { Public declarations }

  end;


var
  Form1: TForm1;

implementation

{$R *.dfm}

var
  SortColumn: Integer;

function ShellCompare(Item1, Item2: Pointer): Integer;
begin
    Result := Smallint(
                  TShellFolder(Item1).ParentShellFolder.CompareIDs(
                  SortColumn,
                  TShellFolder(Item1).RelativeID,
                  TShellFolder(Item2).RelativeID)
              );
end;



procedure TForm1.ShellListView1ColumnClick(Sender: TObject;
  Column: TListColumn);
begin
  SortColumn := Column.Index;
  ShellListView1.FolderList.Sort(ShellCompare);
  ShellListView1.Invalidate;
end;

end.

-- 
Jim

Posted with XanaNews 1.16.1.7

From: Michael Murray  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 10-Feb-2004 at 15:46:7 PST
Not looking for something real industrial strength, just something that will
mimic explorer to show folders and files with appropiate information if in
report mode. I have seen your web page and control before, it is nice, but I
think a little over the top for what I need. I would like to sort it, I have
seen posts like this before, and no one has been able to say definitively
how to sort a TShellListView, I would be willing to modify their source if I
had to. Any help would be appreciated. Thanks.


"Jim Kueneman"  wrote in message
news:402842d5@newsgroups.borland.com...
>
> Hi,
>
> > The problem is the custom sort routine that works in TListView is not
> > working for TShellListView, that is why I posted my question earlier.
> > As for you suggestion, TShellListView does not expose the OnCompare
> > event and the AlphaSort property has no effect. Thanks for your help
> > anyways. Mike
>
>
> That is because the shell sorting is NOT necessisarily alphabetical and
> you have to query the shell to sort correctly.  If you are looking for
> a heavy weight shell components try mine.  If you are looking for a
> simple file browser it is overkill.
>
>
> Yahoo groups support group here:
>
> http://groups.yahoo.com/group/VirtualExplorerTree/
>
> Files here:
>
> http://support.delphi-gems.com/SharePoint/  (VirtualShellTools)
>
> You also need Mike Lischke's Virtual Treeview:
>
> http://support.delphi-gems.com
>
> newgroup support:
>
> news.delphi-gems.com
> delphi-gems.third-party.virtualshelltools
>
>
> --
> Jim
>
> Posted with XanaNews 1.16.1.7



From: Jim Kueneman  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 9-Feb-2004 at 18:32:53 PST
Hi,
 
> The problem is the custom sort routine that works in TListView is not
> working for TShellListView, that is why I posted my question earlier.
> As for you suggestion, TShellListView does not expose the OnCompare
> event and the AlphaSort property has no effect. Thanks for your help
> anyways. Mike


That is because the shell sorting is NOT necessisarily alphabetical and
you have to query the shell to sort correctly.  If you are looking for
a heavy weight shell components try mine.  If you are looking for a
simple file browser it is overkill.


Yahoo groups support group here:

http://groups.yahoo.com/group/VirtualExplorerTree/

Files here:

http://support.delphi-gems.com/SharePoint/  (VirtualShellTools)

You also need Mike Lischke's Virtual Treeview:

http://support.delphi-gems.com

newgroup support:

news.delphi-gems.com
delphi-gems.third-party.virtualshelltools


-- 
Jim

Posted with XanaNews 1.16.1.7

From: Michael Murray  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 9-Feb-2004 at 11:23:5 PST
TShellListView is a control specifically for displaying the contents of your
computer, as my computer or explorer does. All I do is plop the control on
my form, set a property and it populates everything for me, even as I drill
down into folders. If I used TListView, I would have to write all the code
myself to get the contents of all my drives, icons, file sizes, etc. Why do
that when there is a control that does it for me. Unless in Delphi 7 they
changed how TListView works.

The problem is the custom sort routine that works in TListView is not
working for TShellListView, that is why I posted my question earlier. As for
you suggestion, TShellListView does not expose the OnCompare event and the
AlphaSort property has no effect. Thanks for your help anyways. Mike


"Dixon Epperson"  wrote in message
news:40256271$1@newsgroups.borland.com...
> Don't know why you aren't using TListView as opposed to TShellListView.
If
> you were using TListView you would need to populate the two following
> events: OnColumnClick and OnCompare
>
> var
>   ColumnToSort  : integer;
>   bDir : boolean;
>
>
> procedure TForm.ListViewColumnClick(Sender: TObject; Column: TListColumn);
> begin
>   if ColumnToSort = Column.Index then
>     bDir := not bDir  // change direction if same column
>   else begin
>     ColumnToSort := Column.Index;
>     bDir := True;
>   end;
>   ListView.AlphaSort;
> end;
>
> procedure TForm.ListViewCompare(Sender: TObject; Item1, Item2: TListItem;
>   Data: Integer; var Compare: Integer);
> var
>   ix : integer;
> begin
>   if ColumnToSort = 0 then
>     Compare := CompareText(Item1.Caption,Item2.Caption)
>   else begin
>    ix := ColumnToSort - 1;  // first column is the caption, second column
is
> the first sub-item and so forth
>    if not bDir then
>      Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix])
>    else
>      Compare := CompareText(Item2.SubItems[ix],Item1.SubItems[ix])
>   end;
> end;
>
> I've found the TListview very easy to use.  Encourage you to look at it,
and
> the events above may help with your TShellListView
>
>
> "Michael Murray"  wrote in message
> news:4023c312$1@newsgroups.borland.com...
> > I am using the TShellListView component in Delphi 7. The ViewStyle
> property
> > is vsReport. When the user clicks on the column header I want to be able
> to
> > sort that column. By default, clicking the column header does nothing. I
> > tried using the custom sort method in the column click event, but the
> > callback function to sort never gets fired.
> >
> > Does anyone know of a way to sort a TShellListView in report mode, any
> help
> > would be appreciated. Thanks Mike
> >
> >
>
>



From: Dixon Epperson  
Subject: Re: TShellListView and sorting
NewsGroup: borland.public.delphi.vcl.components.using.win32
Date Posted: 7-Feb-2004 at 17:11:5 PST
Don't know why you aren't using TListView as opposed to TShellListView.  If
you were using TListView you would need to populate the two following
events: OnColumnClick and OnCompare

var
  ColumnToSort  : integer;
  bDir : boolean;


procedure TForm.ListViewColumnClick(Sender: TObject; Column: TListColumn);
begin
  if ColumnToSort = Column.Index then
    bDir := not bDir  // change direction if same column
  else begin
    ColumnToSort := Column.Index;
    bDir := True;
  end;
  ListView.AlphaSort;
end;

procedure TForm.ListViewCompare(Sender: TObject; Item1, Item2: TListItem;
  Data: Integer; var Compare: Integer);
var
  ix : integer;
begin
  if ColumnToSort = 0 then
    Compare := CompareText(Item1.Caption,Item2.Caption)
  else begin
   ix := ColumnToSort - 1;  // first column is the caption, second column is
the first sub-item and so forth
   if not bDir then
     Compare := CompareText(Item1.SubItems[ix],Item2.SubItems[ix])
   else
     Compare := CompareText(Item2.SubItems[ix],Item1.SubItems[ix])
  end;
end;

I've found the TListview very easy to use.  Encourage you to look at it, and
the events above may help with your TShellListView


"Michael Murray"  wrote in message
news:4023c312$1@newsgroups.borland.com...
> I am using the TShellListView component in Delphi 7. The ViewStyle
property
> is vsReport. When the user clicks on the column header I want to be able
to
> sort that column. By default, clicking the column header does nothing. I
> tried using the custom sort method in the column click event, but the
> callback function to sort never gets fired.
>
> Does anyone know of a way to sort a TShellListView in report mode, any
help
> would be appreciated. Thanks Mike
>
>