Type | Description | |||
ExShellObjects | An ExShellObjects collection that holds a collection of ExShellObject objects. |
The Objects.Get method gets:
nothing, if the objectType parameter is NoItems
all files or folders being listed in the current view, if the objectType parameter is AllItems
all files or folders being listed in the current view, as they are displayed, if the objectType parameter is AllItems Or AsDisplayed
selected files or folders, if the objectType parameter is SelectedItems
selected files or folders as they are displayed, if the objectType parameter is SelectedItems or AsDisplayed
The following VB6 sample gets a collection of selected items ( in case your control allows multiple selection ):
Private Sub ExShellView1_StateChange(ByVal newState As EXSHELLVIEWLibCtl.StatesEnum) If (newState = SelChangeState) Then ExShellView1.Objects.Get SelectedItems With ExShellView1.Objects For i = 0 To .Count - 1 Debug.Print .Item(i).Name Next End With End If End Sub
In case your control supports single selection, you can use the ObjectSelected event to notify when a new item/object is selected:
Private Sub ExShellView1_ObjectSelected(ByVal Object As EXSHELLVIEWLibCtl.IExShellObject) If Not (Object Is Nothing) Then Debug.Print Object.Name End If End Sub
The following C++ sample displays a message box with the Name of all selected files and folders:
#import <ExShellView.dll> using namespace EXSHELLVIEWLib; void GetSelectedObjects( EXSHELLVIEWLib::IExShellView* pShellView ) { pShellView->GetObjects()->Get(EXSHELLVIEWLib::SelectedItems); EXSHELLVIEWLib::IExShellObjectsPtr spObjects = pShellView->GetObjects(); for ( long i = 0; i < spObjects->Count; i++ ) ::MessageBox( NULL, spObjects->GetItem( i )->Name, NULL, NULL ); }
The following VB.NET sample shows how to get the selected files/folder for /NET assembly version:
Dim i As Long = 0, s As String = "" With Exshellview1 .Objects.Get(exontrol.EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems) With .Objects For i = 0 To .Count - 1 Dim sel As exontrol.EXSHELLVIEWLib.exshellobject = .Item(i) ' * The sel indicates the shell object being selected * s = s + sel.Name + vbCrLf Next End With End With If s.Length > 0 Then MessageBox.Show(s, "Selection") Else MessageBox.Show("Empty", "Selection") End If
The following C# sample shows how to get the selected files/folder for /NET assembly version:
string s = ""; exshellview1.Objects.Get(exontrol.EXSHELLVIEWLib.ObjectTypeEnum.SelectedItems); for ( int i = 0; i < exshellview1.Objects.Count; i++ ) { exontrol.EXSHELLVIEWLib.exshellobject sel = exshellview1.Objects[i]; // * The sel indicates the shell object being selected * s = s + sel.Name + "\r\n"; } if (s.Length > 0) MessageBox.Show(s, "Selection"); else MessageBox.Show("Empty", "Selection");