zoukankan      html  css  js  c++  java
  • Win32 实现 MFC CFileDialog 对话框

     1 void CWriteWnd::OpenFileDialog()
     2 {
     3     OPENFILENAME ofn;      
     4     TCHAR szFile[MAX_PATH] = _T("");
     5 
     6     ZeroMemory(&ofn, sizeof(ofn));  
     7     ofn.lStructSize = sizeof(ofn);
     8     ofn.hwndOwner   = *this;
     9     ofn.lpstrFile   = szFile;   
    10     ofn.nMaxFile    = sizeof(szFile);  
    11     ofn.lpstrFilter = NULL;
    12     ofn.nFilterIndex    = 1;  
    13     ofn.lpstrFileTitle  = NULL;  
    14     ofn.nMaxFileTitle   = 0;  
    15     ofn.lpstrInitialDir = NULL;  
    16     ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
    17 
    18     GetOpenFileName(&ofn);//如果用户指定了一个文件名且点击OK按钮,返回值为非零值。如果用户取消或关闭Save对话框或错误出现,返回值为零。
    19     if (GetOpenFileName(&ofn))  
    20     {
    21         //std::vector<wstring> vctString(1, szFile);//保存添加文件的路径
    22     }
    23    else
    24    {
    25        DWORD dwError = NOERROR;
    26        dwError = CommDlgExtendedError();
    27    }
    28 }

    注:The error codes returned by CommDlgExtendedError are defined in the Cderr.h file.

  • 相关阅读:
    关系运算符重载
    一元运算符重载
    二元运算符重载
    重载函数和重载运算符
    Linux之文件通信
    Linux进程通信之mmap
    Linux之创建多个子进程
    内联函数
    静态成员
    this指针
  • 原文地址:https://www.cnblogs.com/chechen/p/3822356.html
Copyright © 2011-2022 走看看