1.将Dialog的父窗口设为桌面.
2.得到屏幕尺寸再根据比例SetWindowPos.
2.得到屏幕尺寸再根据比例SetWindowPos.
解决方案 »
- win32 api 如何让按钮随着鼠标移动
- windows编程对话框的问题
- [200分] win server 2003 远程桌面问题.
- mfc 搞了很多年了,不知道什么时候会被淘汰?
- 怎么调用excel 保存成html???? 在线等待,真的没人会么???(以后补分!!)
- 怎样去掉分割窗口的分割条?
- 怎样获得网页中指定的内容?
- 再线等待中!关于位图,请问有没有这样的函数,把DIB的部分显示出来或存到内存里!
- 输入法的编写
- 请教各位一个多线程中数据共享的问题,立即加分,先谢了
- 在VC中怎样用pragma告诉编译器某个cpp文件在编译的时候不使用pch预编译?
- 求助:怎么样可以设定CEdit对象在Disable后的字体、颜色(背景、前景)!
不过忘了 :(
dlg.CenterWindow();
试试看,祝你好运!
有空到我的主页去看看。http://shadowsoft.126.com
以下是将调用MessageBox()产生的Dialog居中的例子,不过有些大材小用了.//Set up the CBT hook
threadId = GetCurrentThreadId();
hHook = SetWindowsHookEx(WH_CBT, HookProc, NULL,threadId);int bContinue = ::MessageBox(hParent,"Shutdown HTTP Service?",
"HTTP Service",
MB_YESNO|MB_ICONWARNING);
****************************************
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
RECT rectMsg,rectForm;
if( nCode == HCBT_ACTIVATE )
{
int x,y;
//Get the coordinates of desktop to
//determine where the center of desktop is
GetWindowRect( ::GetDesktopWindow(), &rectForm); GetWindowRect((HWND)wParam, &rectMsg); x = (rectForm.left + (rectForm.right - rectForm.left) / 2) -
((rectMsg.right - rectMsg.left) / 2);
y = (rectForm.top + (rectForm.bottom - rectForm.top) / 2) -
((rectMsg.bottom - rectMsg.top) / 2); // Position the location of msgbox
SetWindowPos( (HWND)wParam, 0, x, y, 0, 0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
//Release the CBT hook
UnhookWindowsHookEx(hHook);
return FALSE;
}
return CallNextHookEx(hHook,nCode,wParam,lParam);
}
AfxGetMainWnd()->CenterWindow();
如果你要改变窗口的宽高则只要重载BOOL CAboutDlg::PreCreateWindow(CREATESTRUCT& cs) 函数,
其中的cs.cx为高, cs.cy为宽
中使用CenterWindow()
或用CenterWindow
CDialog::OnMove(int x, int y)
{
int cx,cy,x,y;
CRect rtMe;
this->GetWindowText(&rtMe);
cx=rtMe.Width();
cy=rtMe.Height();
HWND hDeskWnd=::GetDesktopWindow();
CRect rtDesk;
::GetClientRect(hDeskWnd,&rtDesk);
int m_nScrW=rtDesk.Width();
int m_nScrH=rtDesk.Height();
x=(m_nScrW-cx)/2;
y=(m_nScrH-cy)/2;
this->MoveWindow(x,y,cx,cy);}
::MessageBox(...);
产生的弹出窗口放到desktop的任意指定位置吗?