使用 Propertysheetpage 在 win32 应用程序中创建了两个页面向导。向导未位于屏幕中央。为了将页面定位在中心,我为第一页编写了以下代码(假设第二页将反映在第一页的位置上)但它不起作用。我在这里做错了吗?
static LRESULT WINAPI sWelcomePageDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hwndOwner = NULL;
RECT rcOwner,rcDlg,rc;
switch (uMsg)
{
case WM_INITDIALOG:
hwndOwner = GetDesktopWindow();
GetWindowRect(hwndOwner, &rcOwner);
GetWindowRect(hwnd, &rcDlg);
rc.left = (rcOwner.right - rcOwner.left)/2 - (rcDlg.right - rcDlg.left)/2;
rc.right = rc.left + (rcDlg.right - rcDlg.left);
rc.top = (rcOwner.bottom - rcOwner.top)/2 - (rcDlg.bottom - rcDlg.top)/2;
rc.bottom = rc.top + (rcDlg.bottom - rcDlg.top);
SetWindowPos (hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
SetWindowText(GetDlgItem(hwnd, IDC_WELCOMETEXTSTATIC), Info);
break;
case WM_COMMAND:
break;
case WM_NOTIFY:
LPNMHDR lpnm = (LPNMHDR)lParam;
switch (lpnm->code)
{
case PSN_SETACTIVE:
PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_NEXT | PSWIZB_CANCEL);
break;
case PSN_WIZNEXT:
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, IDD_FINISHPAGE);
break;
}
break;
}
return 0;
}