动态增加菜单后,需要将对话框的大小进行调整。
RECT rtWindow;
::GetWindowRect(hwndDlg, &rtWindow);
::ClientToScreen(hwndDlg, (LPPOINT)&rtWindow);
::ClientToScreen(hwndDlg, ((LPPOINT)&rtWindow) + 1);
// update the size of the owner
rtWindow.bottom += GetSystemMetrics(SM_CXMENUSIZE);;
SetWindowPos(hwndDlg, NULL, rtWindow.left, rtWindow.top, rtWindow.right - rtWindow.left, rtWindow.bottom - rtWindow.top, SWP_NOMOVE | SWP_NOZORDER);
SetMenu(hwndDlg, LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU_MINI_MODE)));
本文介绍了一种在Windows应用程序中动态增加菜单后调整对话框大小的方法。通过使用GetWindowRect和ClientToScreen获取并调整窗口位置,再利用SetWindowPos设置新的窗口尺寸,确保新增菜单适配整个界面。
756

被折叠的 条评论
为什么被折叠?



