请问如何分别创建具有windows标准open功能和browse功能的按钮?谢谢!

解决方案 »

  1.   

    文件打开对话框:
    static char BASED_CODE szFilter[] = _T("All Files(*.*)|*.*||");
     CFileDialog indlg(true, 
     _T("*.*"), 
     NULL,
     OFN_HIDEREADONLY | OFN_ENABLESIZING | OFN_ENABLETEMPLATE,
     szFilter,
     GetParent());
      //在设属性OFN_ENABLETEMPLE下,加自己的控件到文件对话框
    indlg.m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG_FOLDER); 
      //得到WIN2000对话框
    int structsize=0;
    DWORD dwVersion = GetVersion();
    // 如果运行的操作系统是Windows NT/2000,显示新的文件对话框 
    if (dwVersion < 0x80000000)
           structsize = 88; 
    else //运行的操作系统Windows 95/98,显示老的文件对话框  
           structsize = 76;
    indlg.m_ofn.lStructSize=structsize;
    indlg.DoModal();文件夹浏览对话框:
    参考MSDN中的有关函数:
    BROWSEINFO bInfo;
    ::SHBrowseForFolder(&bInfo);
      

  2.   

    CFile f;
    CFileException e;
    char* pFileName = "test.dat";
    if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite, &e ) )
       {
    #ifdef _DEBUG
       afxDump << "File could not be opened " << e.m_cause << "\n";
    #endif
       }