SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
This sample illustrates working with selections.
This is not an executable sample, so a complete project is not provided. These statements are intended to show the syntax used.
// SelectionsDlg.cpp : implementation file // #include "stdafx.h" #include "Selections.h" #include "SelectionsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSelectionsDlg dialog CSelectionsDlg::CSelectionsDlg(CWnd* pParent /*=NULL*/) : CDialog(CSelectionsDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSelectionsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CSelectionsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSelectionsDlg) DDX_Control(pDX, IDC_SFTDIRECTORY1, m_Dir1); DDX_Control(pDX, IDC_SFTDIRECTORY2, m_Dir2); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSelectionsDlg, CDialog) //{{AFX_MSG_MAP(CSelectionsDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) //}}AFX_MSG_MAP END_MESSAGE_MAP() // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CSelectionsDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } HCURSOR CSelectionsDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } BOOL CSelectionsDlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon m_vDir1 = m_Dir1.GetControlUnknown(); m_vDir2 = m_Dir2.GetControlUnknown(); // This sample uses 2 SftDirectory controls // SftDirectory1 allows single selection only m_vDir1->MultiSelect = selectSftDirectorySingle; // SftDirectory2 allows multiple selection m_vDir2->MultiSelect = selectSftDirectoryMultiple; return TRUE; } // This is a button event handler void CSelectionsDlg::OnButton1() { // Select one file/folder (in a single selection control) m_vDir1->FolderList[1]->Selected = VARIANT_TRUE; // Select a few files/folders (in a multiple selection control) m_vDir2->FolderList[1]->Selected = VARIANT_TRUE; m_vDir2->FolderList[3]->Selected = VARIANT_TRUE; m_vDir2->FolderList[5]->Selected = VARIANT_TRUE; } // This is another button event handler void CSelectionsDlg::OnButton2() { // Show the selected file/folder (in a single selection control) ISftDirectoryFolderPtr pFolder; pFolder = m_vDir1->Selection[0]; if (pFolder != NULL) { CString str; CString strName((LPCWSTR)pFolder->Name); str.Format(_T("\"%s\" is selected (in the single selection control)."), strName); AfxMessageBox(str); } // Show the selected files/folders (in a multiple selection control) int i; for (i = 0 ; i < m_vDir2->SelectionCount ; ++ i) { pFolder = m_vDir2->Selection[i]; CString strName((LPCWSTR)pFolder->Name); CString str; str.Format(_T("\"%s\" is selected (in the multiple selection control)."), strName); AfxMessageBox(str); } }