void OnMenuAbout() { if (gHwndAbout) { SetActiveWindow(gHwndAbout); return; } if (!gAtomAbout) { WNDCLASSEX wcex; FillWndClassEx(wcex, ghinst, ABOUT_CLASS_NAME, WndProcAbout); wcex.hIcon = LoadIcon(ghinst, MAKEINTRESOURCE(IDI_SUMATRAPDF)); gAtomAbout = RegisterClassEx(&wcex); CrashIf(!gAtomAbout); } gHwndAbout = CreateWindow( ABOUT_CLASS_NAME, ABOUT_WIN_TITLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ghinst, NULL); if (!gHwndAbout) return; // get the dimensions required for the about box's content RectI rc; PAINTSTRUCT ps; HDC hdc = BeginPaint(gHwndAbout, &ps); UpdateAboutLayoutInfo(gHwndAbout, hdc, &rc); EndPaint(gHwndAbout, &ps); rc.Inflate(ABOUT_RECT_PADDING, ABOUT_RECT_PADDING); // resize the new window to just match these dimensions WindowRect wRc(gHwndAbout); ClientRect cRc(gHwndAbout); wRc.dx += rc.dx - cRc.dx; wRc.dy += rc.dy - cRc.dy; MoveWindow(gHwndAbout, wRc.x, wRc.y, wRc.dx, wRc.dy, FALSE); ShowWindow(gHwndAbout, SW_SHOW); }
static bool CreatePropertiesWindow(HWND hParent, PropertiesLayout* layoutData) { CrashIf(layoutData->hwnd); HWND hwnd = CreateWindow( PROPERTIES_CLASS_NAME, PROPERTIES_WIN_TITLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ghinst, NULL); if (!hwnd) return false; layoutData->hwnd = hwnd; layoutData->hwndParent = hParent; ToggleWindowStyle(hwnd, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, IsUIRightToLeft(), GWL_EXSTYLE); // get the dimensions required for the about box's content RectI rc; PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); UpdatePropertiesLayout(layoutData, hdc, &rc); EndPaint(hwnd, &ps); // resize the new window to just match these dimensions // (as long as they fit into the current monitor's work area) WindowRect wRc(hwnd); ClientRect cRc(hwnd); RectI work = GetWorkAreaRect(WindowRect(hParent)); wRc.dx = min(rc.dx + wRc.dx - cRc.dx, work.dx); wRc.dy = min(rc.dy + wRc.dy - cRc.dy, work.dy); MoveWindow(hwnd, wRc.x, wRc.y, wRc.dx, wRc.dy, FALSE); CenterDialog(hwnd, hParent); ShowWindow(hwnd, SW_SHOW); return true; }