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 implementing a multi-column, multi-selection treeview control with drag & drop, context menus, renaming files/folders, reordering columns.
The source code is located at C:\Program Files (x86)\Softelvdm\SftDirectory 3.5\Samples\VC++\FullTreeView\FullTreeViewDlg.cpp or C:\Program Files\Softelvdm\SftDirectory 3.5\Samples\VC++\FullTreeView\FullTreeViewDlg.cpp (on 32-bit Windows versions).
// FullTreeViewDlg.cpp : implementation file // #include "stdafx.h" #include "FullTreeView.h" #include "FullTreeViewDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFullTreeViewDlg dialog CFullTreeViewDlg::CFullTreeViewDlg(CWnd* pParent /*=NULL*/) : CDialog(CFullTreeViewDlg::IDD, pParent) { //{{AFX_DATA_INIT(CFullTreeViewDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CFullTreeViewDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFullTreeViewDlg) DDX_Control(pDX, IDC_ICONCTRL, m_IconCtrl); DDX_Control(pDX, IDC_BITMAP, m_BitmapCtrl); DDX_Control(pDX, IDC_INFOTIP, m_InfoTipCtrl); DDX_Control(pDX, IDC_SFTDIRECTORY1, m_Dir1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFullTreeViewDlg, CDialog) //{{AFX_MSG_MAP(CFullTreeViewDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFullTreeViewDlg message handlers BOOL CFullTreeViewDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon ISftDirectoryPtr vDir1 = m_Dir1.GetControlUnknown(); vDir1->putref_Font(NULL); return TRUE; // return TRUE unless you set the focus to a control } void CFullTreeViewDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // 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 CFullTreeViewDlg::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(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CFullTreeViewDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CFullTreeViewDlg::OnSelectionFinal_SftDirectory1() { ISftDirectoryPtr vDir1 = m_Dir1.GetControlUnknown(); ISftDirectoryFolderPtr currFolder = vDir1->CurrentFolder; if (currFolder != NULL) { currFolder->GetImage(); m_InfoTipCtrl.SetWindowText(currFolder->InfoTip); } else { m_InfoTipCtrl.SetWindowText(_T("")); } } void CFullTreeViewDlg::OnFolderImageReady_SftDirectory1(LPDISPATCH Folder, LPDISPATCH Picture) { ISftDirectoryPtr vDir1 = m_Dir1.GetControlUnknown(); IPicturePtr pPicture = Picture; m_IconCtrl.ShowWindow(SW_HIDE); m_BitmapCtrl.ShowWindow(SW_HIDE); m_LastPic = Picture; if (m_LastPic != NULL) { short tp; HRESULT hr = m_LastPic->get_Type(&tp); ASSERT(SUCCEEDED(hr)); if (tp == PICTYPE_BITMAP) { OLE_HANDLE hnd; HRESULT hr = m_LastPic->get_Handle(&hnd); ASSERT(SUCCEEDED(hr)); m_BitmapCtrl.SetBitmap((HBITMAP) hnd); m_BitmapCtrl.ShowWindow(SW_SHOW); } else if (tp == PICTYPE_ICON) { OLE_HANDLE hnd; HRESULT hr = m_LastPic->get_Handle(&hnd); ASSERT(SUCCEEDED(hr)); m_IconCtrl.SetIcon((HICON) hnd); m_IconCtrl.ShowWindow(SW_SHOW); } } } BEGIN_EVENTSINK_MAP(CFullTreeViewDlg, CDialog) //{{AFX_EVENTSINK_MAP(CFullTreeViewDlg) ON_EVENT(CFullTreeViewDlg, IDC_SFTDIRECTORY1, 23 /* SelectionFinal */, OnSelectionFinal_SftDirectory1, VTS_NONE) ON_EVENT(CFullTreeViewDlg, IDC_SFTDIRECTORY1, 10 /* FolderImageReady */, OnFolderImageReady_SftDirectory1, VTS_DISPATCH VTS_DISPATCH) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP()