1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
class CFileTransferDlg : public CDialog
{
public:
CFileTransferDlg(CWnd* pParent = NULL); // standard constructor
~CFileTransferDlg();
CPcTreeCtrl m_PcTreeCtrl;
CPcListCtrl m_PcListCtrl;
protected:
CImageList *m_pPcTreeCtrlImageList;
CImageList *m_pPcListCtrlImageList;
};
CFileTransferDlg::CFileTransferDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFileTransferDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFileTransferDlg)
//}}AFX_DATA_INIT
m_pPcTreeCtrlImageList = NULL;
m_pPcListCtrlImageList = NULL;
}
BOOL CFileTransferDlg::OnInitDialog()
{
CDialog::OnInitDialog();
(...)
CString strPcPath= "D:\\Test\\";
//----------------------------------------
// Creates an ImageList
//----------------------------------------
SHFILEINFO sfi;
HIMAGELIST hSystemImageList = (HIMAGELIST) SHGetFileInfo(_T("C:\\"), 0, &sfi, sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
m_pPcTreeCtrlImageList = new CImageList();
m_pPcListCtrlImageList = new CImageList();
ASSERT(m_pPcTreeCtrlImageList != NULL && m_pPcListCtrlImageList != NULL); // serious allocation failure checking
VERIFY(m_pPcTreeCtrlImageList->Attach(hSystemImageList));
m_PcTreeCtrl.SetImageList(m_pPcTreeCtrlImageList, TVSIL_NORMAL);
m_pPcTreeCtrlImageList->Detach();
VERIFY(m_pPcListCtrlImageList->Attach(hSystemImageList));
m_PcListCtrl.SetImageList(m_pPcListCtrlImageList, LVSIL_SMALL);
(...)
//---------------------------------------------
//Display the folder items in the Pc Tree
//---------------------------------------------
m_PcTreeCtrl.DisplayDrives(TVI_ROOT, FALSE);
m_PcTreeCtrl.SetSelectedPath(strPcPath, 1);
//----------------------------------------
// Add columns to the list ctrl.
//----------------------------------------
m_PcListCtrl.InsertColumn (0, _T ("Nom"), LVCFMT_LEFT, 170);
m_PcListCtrl.InsertColumn (1, _T ("Taille"), LVCFMT_RIGHT, 70);
m_PcListCtrl.InsertColumn (2, _T ("Modifié le"), LVCFMT_LEFT, 100);
//---------------------------------------------
// Initialize m_pPcListCtrl & m_pPcTreeCtrl
//---------------------------------------------
m_PcTreeCtrl.m_pPcListCtrl = &m_PcListCtrl;
m_PcListCtrl.m_pPcTreeCtrl = &m_PcTreeCtrl;
//----------------------------------------
// Populate the list ctrl with items.
//----------------------------------------
m_PcListCtrl.DisplayPath (strPcPath);
} |
Partager