Moving a dialog control when resizing a dialog box so that they are compatible between operating systems using mfc C ++

I am currently moving the dialog box controls when the dialog box changes as follows:

// Get the list control rect.
CRect listRect;
list->GetWindowRect(&listRect);
ScreenToClient(listRect);

// Get the dialog Rect.
CRect dialogRect;
GetWindowRect(&dialogRect);
ScreenToClient(dialogRect);

list->MoveWindow(listRect.left, listRect.top,
                 dialogRect.right - (2 * listRect.left), dialogRect.bottom - 100);

This works fine in Windows XP, but when I tried it in Windows Vista, positioning was disabled. I think it should be up to the large border and title dialogs in the Windows Vista dialog box, as well as the fact that it GetWindowRecthas the following entry in the documentation:

Dimensions are shown in screen coordinates relative to the upper left corner of the display screen. The sizes of the headers, borders, and scrollbars, if any, are included.

, , , ?

+3
1

GetClientRect GetWindowRect, ScreenToClient - (.. ), , ( ).

// Get the list control rect.
CRect listRect;
list->GetWindowRect(&listRect);
dlg->ScreenToClient(&listRect);

// Get the dialog Rect.
CRect dialogRect;
dlg->GetClientRect(&dialogRect);

list->MoveWindow(listRect.left, listRect.top, dialogRect.right - (2 * listRect.left), dialogRect.bottom - 100);
+2

Source: https://habr.com/ru/post/1780653/


All Articles