码迷,mamicode.com
首页 > Windows程序 > 详细

Win32 SDK - 打开文件对话框

时间:2014-12-18 13:19:26      阅读:365      评论:0      收藏:0      [点我收藏+]

标签:style   ar   sp   for   on   文件   log   bs   amp   

 

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);
}

 

 

Win32 SDK - 打开文件对话框

标签:style   ar   sp   for   on   文件   log   bs   amp   

原文地址:http://www.cnblogs.com/huhu0013/p/4171373.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!