Win32 SDK - 打開文件對話框


 

OPENFILENAME ofn;     // common dialog box structure
TCHAR szFile[MAX_PATH];  // buffer for file name

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';    //
               // Set lpstrFile[0] to '\0' so that GetOpenFileName does not
               // use the contents of szFile to initialize itself.
               //
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("Text files (*.txt)\0*.txt\0\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.lpstrTitle = _T("打開");  // set the dialog box title

if (GetOpenFileName(&ofn))
{
  SetDlgItemText(hwndDlg, IDC_EDIT1, szFile);
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM