请问CFileDialog如何设定它的窗口弹出位置?
下面代码,不能实现,请只教:CFileDialog Dlg(true,NULL, ExtendName.c_str(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
ExtendShow.c_str(), CWnd::FromHandle(m_hWnd) );
RECT rc;
Dlg.GetWindowRect(&rc);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2;
Dlg.MoveWindow(x,y,(rc.right-rc.left),(rc.bottom-rc.top),false);
CString DlgFileName;
if(Dlg.DoModal()==IDOK)
{
DlgFileName=Dlg.GetPathName();
}
下面代码,不能实现,请只教:CFileDialog Dlg(true,NULL, ExtendName.c_str(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
ExtendShow.c_str(), CWnd::FromHandle(m_hWnd) );
RECT rc;
Dlg.GetWindowRect(&rc);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2;
Dlg.MoveWindow(x,y,(rc.right-rc.left),(rc.bottom-rc.top),false);
CString DlgFileName;
if(Dlg.DoModal()==IDOK)
{
DlgFileName=Dlg.GetPathName();
}
解决方案 »
- IOCP 重复发送数据的问题
- 怎么样设置CComboBox属性,当选中它 时不能对它进行编辑,编辑框中的内容只能够从下拉列表里选择
- 对话框中的CComboBox控件?
- "ox0049e4a0"指令引用的“0x00000004”内存,该内存不能为witten.
- Error Show
- 简单题高分送。帮小弟看看吧,都是基础的
- POPUP菜单里可以加 &C, 如果想加CTRL+C怎么加
- 注册表里的{8DE0FCD4-5EB5-11D3-AD25-00002100131B}这种是什么意思?
- ~~~~~~~~~~~~~~~做了一个控件,遇到一些小麻烦,是高手的进来看看~~~~~~~~~~~~~~
- 有没有从DNS来得到服务器的IP的方法?
- 如何在一个不规则的区域进行透明位图的操作,在线等待
- 我在某一个函数中使用了指针,而且是NEW,需要delete吗?
CString DlgFileName;
if(Dlg.DoModal()==IDOK)
{
DlgFileName=Dlg.GetPathName();
}
RECT rc;
Dlg.GetWindowRect(&rc);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2;
Dlg.MoveWindow(x,y,(rc.right-rc.left),(rc.bottom-rc.top),false);这样也不行啊?为什么呢?
Dlg.GetWindowRect(&rc);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2;
Dlg.MoveWindow(x,y,(rc.right-rc.left),(rc.bottom-rc.top),false);if(Dlg.DoModal()==IDOK)
{
DlgFileName=Dlg.GetPathName();
}
CString DlgFileName;
if(Dlg.DoModal()==IDOK)
{
DlgFileName=Dlg.GetPathName();
}
RECT rc;
Dlg.GetWindowRect(&rc);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2;
Dlg.MoveWindow(x,y,(rc.right-rc.left),(rc.bottom-rc.top),false);不能弹出窗体,请只教,谢谢!!!!!!!!!1
if(Dlg.DoModal()==IDOK)//单击OK后,窗口都消失了,以后再移动窗口位置当然不行了
{
DlgFileName=Dlg.GetPathName();
}
RECT rc;
Dlg.GetWindowRect(&rc);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2;
Dlg.MoveWindow(x,y,(rc.right-rc.left),(rc.bottom-rc.top),false);
将你的CFileDialog定义为成员指针变量
CFileDialog* m_pdlg;
在你要显示对话框的函数中SetTimer(102, 10, NULL);m_pdlg = new CFileDialog(true,NULL, ExtendName.c_str(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,ExtendShow.c_str(), CWnd::FromHandle(m_hWnd) );
m_pdlg->DoModal();
delete m_pdlg;然后,响应WM_TIMER消息
在该消息处理函数中加上
if(nIDEvent == 102){
KillTimer(nIDEvent);
int x=(MainFrameRect.right-MainFrameRect.left)/2-(rc.right-rc.left)/2;
int y=(MainFrameRect.bottom-MainFrameRect.top)/2-(rc.bottom-rc.top)/2; m_pdlg->GetParent()->SetWindowPos(NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}当然,你也可以派生CFileDialog,进行移动
可能也可以写OPENFILENAME的LPOFNHOOKPROC,不过没试过,不知道成不成
CHAR szFile[MAX_PATH] = "\0";
CHAR szSystem32[MAX_PATH];
strcpy( szFile, "");
ZeroMemory(&OpenFileName, sizeof(OPENFILENAME));
// 填充 OPENFILENAME 结构以支持模板和挂接。
OpenFileName.lStructSize = sizeof(OPENFILENAME);
OpenFileName.hwndOwner = this->GetSafeHwnd();
OpenFileName.hInstance = NULL;
OpenFileName.lpstrFile = szFile;
OpenFileName.nMaxFile = sizeof(szFile);
OpenFileName.lpstrTitle = "Select a File";
OpenFileName.Flags = OFN_FILEMUSTEXIST; szSystem32[0] = '\0';
OpenFileName.lpstrInitialDir = szSystem32;
// 调用公共对话函数。
if (GetOpenFileName(&OpenFileName))
请问如何设定上面对话框的位置?