这样子写没有起作用:
int CALLBACK PropSheetCallback(HWND hDlg, UINT uMsg, LPARAM lParam)
{
if(uMsg == PSCB_INITIALIZED)
{
int cx,cy;
RECT rcFrame,rcPS;
GetClientRect(GetParent(hDlg),&rcFrame);
GetWindowRect(hDlg,&rcPS);
cx=((rcFrame.right-rcFrame.left)-(rcPS.right-rcPS.left))/2;
cy=((rcFrame.bottom-rcFrame.top)-(rcPS.bottom-rcPS.top))/2;
SetWindowPos(hDlg,HWND_TOP,cx,cy,-1,-1,SWP_NOSIZE );
int CALLBACK PropSheetCallback(HWND hDlg, UINT uMsg, LPARAM lParam)
{
if(uMsg == PSCB_INITIALIZED)
{
int cx,cy;
RECT rcFrame,rcPS;
GetClientRect(GetParent(hDlg),&rcFrame);
GetWindowRect(hDlg,&rcPS);
cx=((rcFrame.right-rcFrame.left)-(rcPS.right-rcPS.left))/2;
cy=((rcFrame.bottom-rcFrame.top)-(rcPS.bottom-rcPS.top))/2;
SetWindowPos(hDlg,HWND_TOP,cx,cy,-1,-1,SWP_NOSIZE );
可以试试 CenterWindow
的函数。我的是win32工程。