home *** CD-ROM | disk | FTP | other *** search
- // Copyright ⌐ 1998 Plasmatech Software Design. You can use code from this file in your own projects without credit.
- //---------------------------------------------------------------------------
- #include <vcl\vcl.h>
- #pragma hdrstop
-
- #include "FMain.h"
- #include "PTShConsts.h"
- //---------------------------------------------------------------------------
- #pragma link "UPTSplitter"
- #pragma link "UPTShellControls"
- #pragma link "UPTTreeList"
- #pragma resource "*.dfm"
- TFrmMain *FrmMain;
- //---------------------------------------------------------------------------
- __fastcall TFrmMain::TFrmMain(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- /*
- This OnInsert event is called after each list item is added to the control.
- The TPTShListData object for the item can be retrieved with the
- GetDataFromItem method as shown.
-
- The call to PTShellList1->Folder->PathName is relatively CPU expensive for
- such a frequently called routine, so it is only called for the first item
- added to the listview.
- */
- void __fastcall TFrmMain::PTShellList1Insert(TObject *Sender, TListItem *Item)
- {
- if (PTShellList1->Items->Count == 1)
- FIsFolder = ! PTShellList1->Folder->PathName.IsEmpty();
-
- if (FIsFolder)
- Item->SubItems->Strings[0] = "(" + PTShellList1->GetDataFromItem(Item)->DisplayName + ")";
- }
- //---------------------------------------------------------------------------
- /*
- This OnFillComplete event is called at the end of fill process for the
- listview control. It is here we add the custom column and remove all but
- the 'Name' system columns.
- */
- void __fastcall TFrmMain::PTShellList1FillComplete(TObject *Sender)
- {
- if (! PTShellList1->Folder->PathName.IsEmpty()) { // Can't use FIsFolder since OnInsert won't be called if there are no items.
- PTShellList1->Columns->BeginUpdate();
- try {
- TListColumn* lc = PTShellList1->Columns->Add(); // Add our new column first, otherwise the SubItems we just added will be deleted
- lc->Caption = "My Column";
- if (PTShellList1->Items->Count > 0)
- lc->Width = -1; // Autosize to widest item
- else
- lc->Width = 100;
-
- while (PTShellList1->Columns->Count > 2) // Delete all other columns, leaving the Name and custom columns.
- delete PTShellList1->Columns->Items[1];
-
- PTShellList1->Columns->EndUpdate();
- }
- catch(...) {
- PTShellList1->Columns->EndUpdate();
- throw;
- }
- }
- }
- //---------------------------------------------------------------------------
-
-