注册 登录
编程论坛 VC++/MFC

问个粗浅的MFC新手的问题~

wube 发布于 2012-02-06 11:39, 692 次点击
只有本站会员才能查看附件,请 登录

1.这个对话框是
class CCommonDialog : public CDialog
...
class CFileDialog : public CCommonDialog
...
void CxxxxxxDlg::OnOpenFile()
这样搞出来的

只有本站会员才能查看附件,请 登录

2.那这个对话框是怎么搞出来的?

只有本站会员才能查看附件,请 登录

3.那这个对话框又是加了什么搞出来的?
6 回复
#2
hahayezhe2012-02-06 16:02
CFileDialog m_filedialog(FALSE/TRUE);
m_filedialog.domodel()
#3
wube2012-02-06 19:50
那是第一个~原来可以写这么短~

第二个我找出来了~
程序代码:

        // TODO: Add your control notification handler code here
    BROWSEINFO bi={0};
    bi.hwndOwner=this->m_hWnd;
    bi.lpszTitle=" Select Folder ... ";
    LPITEMIDLIST pIIL=SHBrowseForFolder(&bi);
    if(pIIL)
    {
        CString FPath;
        SHGetPathFromIDList(pIIL,FPath.GetBuffer(256));
        FPath.ReleaseBuffer();

        IMalloc *pmal=0;
        if(SHGetMalloc(&pmal)==S_OK)
        {
            pmal->Free(pIIL);
            pmal->Release();
        }
        //AfxMessageBox(FPath);
        if (FPath !="")
        {
            m_TargetPath.SetWindowText(FPath);
            OutputFilePath=FPath;
        }
    }


第三个我也找出来了~

        enum modes{NONE=0,PATHTEXT=16,NEWFOLDER=64};
    bi.ulFlags=NEWFOLDER;
#4
wube2012-02-06 19:53
第二个是网路找到的~
第三个是跟着第二个参考的VB6程式码凑出来的~
#5
wube2012-02-07 19:30
第三个更短的~
程序代码:

        CFileDialogST dlg;
    int nRetValue;
    CString    sFolder;

    nRetValue = dlg.SelectFolder(_T("Please select a destination folder"), _T("c:\\"), 0x40|BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS, this);
    if (nRetValue == IDOK)
    {
        sFolder = dlg.GetSelectedFolder();
        MessageBox(sFolder, _T("GetSelectedFolder"), MB_ICONINFORMATION);
        }
#6
wube2012-02-07 19:33
Save Code :
程序代码:

        CFileDialogST dlg(FALSE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST, _T("All files\0*.*\0"), this);
    CString    sPathName;
    int nRetValue;

    nRetValue = dlg.DoModal();
    if (nRetValue == IDOK)
    {
        sPathName = dlg.GetPathName();
        MessageBox(sPathName, _T("GetPathName"), MB_ICONINFORMATION);
    }
#7
习惯被动2012-07-10 14:27
回复 楼主 wube
楼主,请问你那个图片怎么发上去的?
1