使用属性表将向导定位在屏幕 win32 应用程序的中心
Positioning wizard at the centre of the screen win32 application using propertysheet
使用属性表页在 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;
}
传递到窗口进程的 hwnd 是向导页的句柄。有关向导本身的句柄,请调用 GetParent( hwnd)。
顺便说一句,屏幕尺寸也可以通过GetSystemMetrics(),SM_CXSCREEN/SM_CYSCREEN获得。
相关文章:
- Win32编译器选项和内存分配
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- 如何在GTK程序运行时禁用屏幕保护程序/电源管理/屏幕消隐
- 使用 SFML 和 C++ 将 Pixel 打印到屏幕上
- C++win32 API创建多个类似视口的窗口
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- 检测win32服务创建和删除的最佳方法
- WIN32:C++,为什么在WM_CLOSE上调用Messagebox函数程序正在冻结
- 将 win32 hbitmap 转换为 winrt softwarebitmap
- 使用 WIN32 API (C/C++) 对特定树视图项进行着色
- 在 Windows 8/10 技术中完全实时的屏幕捕获,没有延迟
- Alt+Enter 在 Win32 应用中,管理大小调整和分辨率
- VSCode C++ 编译的exe感染了Win32:TrojanX-gen[Trj]
- 从预处理器获取 Windows 版本(C++ Win32)
- 如何在 Win32 应用中拖动纯色矩形,而不会产生白色闪烁,也不会干扰其他屏幕对象
- 使用属性表将向导定位在屏幕 win32 应用程序的中心
- 如何在Win32 API中从屏幕捕获中排除某些窗口
- Win32 c++控制台清除屏幕不眨眼
- Win32屏幕保护程序多显示器与主显示器不是最左边
- 在c++ (Win32)中快速获取Windows应用程序的屏幕截图