谢谢!
解决方案 »
- 程序错在哪啦??大侠们 我快疯了 帮帮我吧~~
- 关于setTimer()和onTimer?在线
- 问一个问题,没有lib能不能使用响应的DLL呢?
- 怎么解决"LINK : warning LNK4089: /OPT:REF 已丢弃所有对“SHELL32.dll”的引用"
- 问题紧急,望各位不吝赐教!!
- 怎么改显示器的刷新频率,谢谢
- VC努力自学一年,你认为应该达到什么水平才算不枉花了那么多时间??
- 开口就有分
- 问一个初级问题
- 关于List Box控件的一个小问题,望大家帮帮忙!!!
- 请强烈关注:有没有兄弟在浙江华美,杭州恒生,上海海信科技中呆过的?有一非常NIU人的简历我想验证一下
- 关于Richedit问题
nWidth = (rChild.right - rChild.left);
nHeight = (rChild.bottom - rChild.top); // calculate parent window center point
pCenter.x = rParent.left+((rParent.right
- rParent.left)/2);
pCenter.y = rParent.top+((rParent.bottom
- rParent.top)/2); // calculate message box starting point
pStart.x = (pCenter.x - (nWidth/2));
pStart.y = (pCenter.y - (nHeight/2));
// adjust if message box is off desktop
if(pStart.x < 0) pStart.x = 0;
if(pStart.y < 0) pStart.y = 0;
if(pStart.x + nWidth > rDesktop.right)
pStart.x = rDesktop.right - nWidth;
if(pStart.y + nHeight > rDesktop.bottom)
pStart.y = rDesktop.bottom - nHeight; // move message box
MoveWindow(hChildWnd,
pStart.x, pStart.y,
nWidth, nHeight,
FALSE);具体的例子
http://www.codeguru.com/Cpp/W-P/win32/messagebox/article.php/c4541/
这个是子窗体位于主窗体的中央吧
HWND hChild; //Child window handle.
HWND hParent; //Parent window handle.
CSize size;
CRect ChildRect;
CRect ParentRect;
GetWindowRect(hChild,&ChildRect);
GetWindowRect(hParent,&ParentRect);size.cx = (ParentRect.right - ChildRect.right)/2;
size.cy = (ParentRect.bottom - ChildRect.bottom)/2;
CRect ChildRect;
CRect ParentRect;CDialog* pDlg = new CDialog();
pDlg->Create(IDD_MYDIALOG,this); //从资源中上装入对话框pDlg->GetWindowRect(&ChildRect);
GetWindowRect(&ParentRect);size.cx = (ParentRect.right - ChildRect.right)/2;
size.cy = (ParentRect.bottom - ChildRect.bottom)/2;pDlg->MoveWindow(size.cx,size.cx,ChildRect.right,ChildRect.bottom,TRUE);
PDlg->ShowWindow(SW_SHOWNORMAL);
CWnd* pAlternateOwner = NULL
);
//这个函数也可以帮你实现