| 655 | } |
| 656 | |
| 657 | void JsonViewDlg::AdjustDocPanelSize(int nWidth, int nHeight) |
| 658 | { |
| 659 | // Calculate desktop scale. |
| 660 | float fDeskScale = CUtility::GetDesktopScale(_hSelf); |
| 661 | |
| 662 | auto newDeltaWidth = nWidth - m_lfInitialClientWidth - 2; // -2 is used for margin |
| 663 | auto addWidth = static_cast<int>((newDeltaWidth - m_lfDeltaWidth) * fDeskScale); |
| 664 | m_lfDeltaWidth = newDeltaWidth; |
| 665 | |
| 666 | auto newDeltaHeight = nHeight - m_lfInitialClientHeight; |
| 667 | auto addHeight = static_cast<int>((newDeltaHeight - m_lfDeltaHeight) * fDeskScale); |
| 668 | m_lfDeltaHeight = newDeltaHeight; |
| 669 | |
| 670 | // elements that need to be resized horizontally |
| 671 | const auto resizeWindowIDs = {IDC_EDT_SEARCH, IDC_TREE}; |
| 672 | |
| 673 | // elements that need to be moved |
| 674 | const auto moveWindowIDs = {IDC_BTN_SEARCH}; |
| 675 | |
| 676 | // elements which requires both resizing and move |
| 677 | const auto resizeAndMoveWindowIDs = {IDC_EDT_NODEPATH}; |
| 678 | |
| 679 | const UINT flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_SHOWWINDOW; |
| 680 | |
| 681 | RECT rc; |
| 682 | for (int id : resizeWindowIDs) |
| 683 | { |
| 684 | HWND hWnd = ::GetDlgItem(_hSelf, id); |
| 685 | ::GetWindowRect(hWnd, &rc); |
| 686 | int cx = rc.right - rc.left + addWidth; |
| 687 | int cy = rc.bottom - rc.top; |
| 688 | |
| 689 | if (id == IDC_TREE) |
| 690 | cy += addHeight; |
| 691 | |
| 692 | ::SetWindowPos(hWnd, NULL, 0, 0, cx, cy, SWP_NOMOVE | flags); |
| 693 | } |
| 694 | |
| 695 | for (int id : moveWindowIDs) |
| 696 | { |
| 697 | HWND hWnd = GetDlgItem(_hSelf, id); |
| 698 | ::GetWindowRect(hWnd, &rc); |
| 699 | ::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rc, 2); |
| 700 | |
| 701 | ::SetWindowPos(hWnd, NULL, rc.left + addWidth, rc.top, 0, 0, SWP_NOSIZE | flags); |
| 702 | } |
| 703 | |
| 704 | for (int id : resizeAndMoveWindowIDs) |
| 705 | { |
| 706 | HWND hWnd = GetDlgItem(_hSelf, id); |
| 707 | |
| 708 | ::GetWindowRect(hWnd, &rc); |
| 709 | int cx = rc.right - rc.left + addWidth; |
| 710 | int cy = rc.bottom - rc.top; |
| 711 | ::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rc, 2); |
| 712 | |
| 713 | ::SetWindowPos(hWnd, NULL, rc.left, rc.top + addHeight, cx, cy, flags); |
| 714 | } |
nothing calls this directly
no outgoing calls
no test coverage detected