BOOL CDiskCataDlg::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
imlst.Create(16,16,ILC_COLOR32|ILC_MASK,0,0); //创建图像列表
m_trdisktree.SetImageList(&imlst,TVSIL_NORMAL); //关联图像列表
m_trdisktree.ModifyStyle(0L,TVS_HASLINES|TVS_LINESATROOT);//修改控件属性
size_t alldriver=::GetLogicalDriveStrings(0,NULL);//获取磁盘分区
_TCHAR *driverstr;
driverstr=new _TCHAR[alldriver+sizeof(_T(""))];
if(GetLogicalDriveStrings(alldriver,driverstr)!=alldriver-1)//获取磁盘目录
return FALSE;
_TCHAR *pdriverstr=driverstr;
size_t driversize=strlen(pdriverstr);
HTREEITEM disktree;
while(driversize>0)
{
SHGetFileInfo(pdriverstr,0,&fileinfo,sizeof(fileinfo),
SHGFI_ICON); //获取系统文件图标
imindex=imlst.Add(fileinfo.hIcon);
//插入到树控件
disktree=m_trdisktree.InsertItem(pdriverstr,imindex,imindex,TVI_ROOT,TVI_LAST);
pdriverstr+=driversize+1;
driversize=strlen(pdriverstr);
}
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CDiskCataDlg::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); C.