class CMyFileDialog: public CFileDialogImpl
{
public:
CMyFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL,
HWND hWndParent = NULL)
: CFileDialogImpl
// Maps
BEGIN\_MSG\_MAP(CMyFileDialog)
CHAIN\_MSG\_MAP(CFileDialogImpl<CMyFileDialog>)
END\_MSG\_MAP()
//重载此函数;实现居中
void OnInitDone ( LPOFNOTIFY lpon )
{
GetFileDialogWindow().CenterWindow(lpon->lpOFN->hwndOwner);
}
};
重写FileDialog,重载OnInitDone,实现居中,引用代码如下:
void xxx::SelectUpgradeFile()
{
char szFilters[] = _T("升级文件 (*.ram)\0*.ram\0全部文件(*.*)\0*.*\0\0");
CMyFileDialog fileDlg(TRUE,NULL, NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,szFilters );//szFilters
char strBuffer\[MAX\_PATH\] = {};
fileDlg.m\_ofn.lpstrFile = strBuffer;
fileDlg.m\_ofn.nMaxFile = MAX\_PATH;
if (fileDlg.DoModal() != IDOK)
{
ImmsMessageBox(m\_PaintManager.GetPaintWindow(),\_T("升级设备失败!"),\_T("提示"),MB\_OK);
return ;
}
m\_strEquipmentUpgradeFileName = fileDlg.m\_ofn.lpstrFile;
if (m\_strEquipmentUpgradeFileName.Right().CompareNoCase(".ram")!=)
{
ImmsMessageBox(m\_PaintManager.GetPaintWindow(),\_T("选择的文件不是编解码器升级文件!"),\_T("提示"),MB\_OK|MB\_ICONERROR);
return ;
}
CEditUI \*pFileName = static\_cast<CEditUI \*>(m\_PaintManager.FindControl(ctrl\_device\_data\_manager\_decoder\_equi\_upgrade\_select\_file));
if(!pFileName)
return;
pFileName->SetText(m\_strEquipmentUpgradeFileName);
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章