传入的结构体参数:
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lpstrFile = 初始文件名;ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = _T("Text Files(*.txt)|*.txt|All Files(*.*)|*.*||");
ofn.lpstrDefExt = _T("txt");
ofn.lpstrTitle = _T("保存为");
ofn.hInstance = GetModuleHandle(NULL);
ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK | OFN_EXPLORER;
ofn.hwndOwner = 父窗口句柄;
ofn.FlagsEx = OFN_EX_NOPLACESBAR;
ofn.lpfnHook = OFNHookProc;
ofn.lpstrInitialDir = prtMainFrame->InitPaht.c_str();
ofn.lStructSize = sizeof(OPENFILENAME);
// 让窗口居中显示,主要是设置Hook函数,在Flags标志中必须设置OFN_ENABLEHOOK | OFN_EXPLORER,具体的作用请看msdn
下面看一下Hook函数的编写方法:
UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
<