Posted by creeek on March 01, 2004 I am trying to ceate a 'file organiser' program for education and personal use. it is 90% done. I cant appear to get the ShellTreeView function to work properly. All I want to do is 'simple'?!?! Create a direcory (or folder) in the ShellTreeView (obviously linked to ShellListView and ShellComboBox) When I delete a folder, this appears to work OK: To make things easier, I have done a shortened version with form1, Shellcombobox1, ShellTreeView1, ShellListView1 (the 3 are linked normally), also added edit1 and 2 buttons for clicking and making or deleting folders! The full code is: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ShellCtrls, StdCtrls, QfileCtrls; type TForm1 = class(TForm) ShellListView1: TShellListView; ShellComboBox1: TShellComboBox; ShellTreeView1: TShellTreeView; ListBox1: TListBox; Button1: TButton; Button2: TButton; Edit1: TEdit; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure ShellListView1Click(Sender: TObject); procedure ShellListView1ColumnClick(Sender: TObject; Column: TListColumn); procedure ShellTreeView1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} // *** TRIED to keep simple.......... ************************ procedure TForm1.FormCreate(Sender: TObject); begin ShellCombobox1.Root := 'C:\'; edit1.Text := ShellCombobox1.Path; ShellListView1.ViewStyle := VSreport; // show columns for SORTING! how to implement??? end; procedure TForm1.Button1Click(Sender: TObject); var Lcount : Integer; TreeNode : TTreenode; item: TListItem; begin //******** MAKE FOLDER, does not work as expected??? :( *** Lcount := 0; while Lcount 0 then MessageDlg('Error creating directory', mtWarning, [mbOk], 0); Shelltreeview1.Items[Lcount].Expand(True); end; Lcount := Lcount +1; end; // end of the While end; procedure TForm1.Button2Click(Sender: TObject); var SelectFolder : integer; begin // Delete selected dir, Works perfectly! ShellTreeview1.Items.BeginUpdate; SelectFolder := 0; while SelectFolder <> ShellListView1.Folders[ListItem.Index].PathName then edit1.Text:= ShellListView1.Folders[ListItem.Index].PathName; if SelectedFolder.IsFolder = False then // select a FOLDER ONLY edit1.Text := ExtractFileDir(edit1.text); end; // end of the 'with' end; procedure TForm1.ShellListView1ColumnClick(Sender: TObject; Column: TListColumn); var listItem : Tlistitem; count : integer; begin // *** ANY BODY HELP HERE???? TO SORT COLUMNS??? ******* // Column.caption is: Name/ size/modified etc end; procedure TForm1.ShellTreeView1Click(Sender: TObject); var tree : TTreenode; temp : integer; label exit1; begin tree := ShelltreeView1.TopItem; temp := 0; if ShellTreeView1 = nil then exit; // this does stop exception?! while temp < ShelltreeView1.Items.Count do begin if ShellTreeView1.Items[temp].Selected = true then begin ShellTreeView1.Items[temp].Focused := True; edit1.Text := ShellTreeView1.SelectedFolder.PathName; end; temp := temp +1; end; end; end. To see the problem, select a folder and click the 'Make Folder' button, you will see 'ghost' 'NewFolder' will have been created in the ShellTreeView and it IS on the hard drive, but the ShellTreeView cant be clicked on without causing an exception I starrt ed to think the .paint function would help, but it does not :( Mick
Search for: ShellTreeView
|
|