private void ResizeCustomControl(IntPtr hWnd) { if (hWnd == m_hWnd) { IntPtr hSelectButton = hWnd.AssumeNonZero().GetDlgItem(InteropUtil.ID_SELECT).AssumeNonZero(); IntPtr hOkButton = hWnd.AssumeNonZero().GetDlgItem(InteropUtil.ID_CUSTOM_CANCEL).AssumeNonZero(); IntPtr hParent = hWnd.GetParent().AssumeNonZero(); IntPtr fileName = hParent.GetDlgItem(InteropUtil.ID_FileNameCombo).AssumeNonZero(); /*var right = fileName.GetWindowPlacement().Right; * var top = hSelectButton.GetWindowPlacement().Top;*/ InteropUtil.RECT rect = new InteropUtil.RECT(); InteropUtil.WINDOWPLACEMENT selectRect = hSelectButton.GetWindowPlacement(); rect.top = selectRect.Top; rect.bottom = selectRect.Bottom; rect.right = fileName.GetWindowPlacement().Right; rect.left = rect.right - (m_cancelWidth + m_buttonGap + m_selectWidth); ResizeCustomControl(hWnd, rect, hOkButton, hSelectButton); } }
private void ResizeCustomControl(IntPtr hWnd, InteropUtil.RECT rect, params IntPtr[] buttons) { DialogBrowsingUtilities.Assume(buttons != null && buttons.Length > 0); hWnd.AssumeNonZero(); InteropUtil.WINDOWPLACEMENT wndLoc = hWnd.GetWindowPlacement(); wndLoc.Right = rect.right; hWnd.SetWindowPlacement(ref wndLoc); foreach (IntPtr hBtn in buttons) { m_calcPosMap[hBtn.GetDlgCtrlID()](this, rect.right, out int btnRight, out int btnWidth); PositionButton(hBtn, btnRight, btnWidth); } IntPtr hRgn = InteropUtil.CreateRectRgnIndirect(ref rect); try { if (hWnd.SetWindowRgn(hRgn, true) == 0) { //setting the region failed, so we need to delete the region we created above. hRgn.DeleteObject(); } } catch { if (hRgn != IntPtr.Zero) { hRgn.DeleteObject(); } } }
private void ResizeCustomControl(IntPtr hWnd) { if (hWnd == m_hWnd) { IntPtr hSelectButton = InteropUtil.AssumeNonZero(InteropUtil.GetDlgItem(InteropUtil.AssumeNonZero(hWnd), InteropUtil.ID_SELECT)); IntPtr hOkButton = InteropUtil.AssumeNonZero(InteropUtil.GetDlgItem(InteropUtil.AssumeNonZero(hWnd), InteropUtil.ID_CUSTOM_CANCEL)); IntPtr hParent = InteropUtil.AssumeNonZero(InteropUtil.GetParent(hWnd)); IntPtr fileName = InteropUtil.AssumeNonZero(InteropUtil.GetDlgItem(hParent, InteropUtil.ID_FileNameCombo)); /*var right = fileName.GetWindowPlacement().Right; var top = hSelectButton.GetWindowPlacement().Top;*/ var rect = new InteropUtil.RECT(); InteropUtil.WINDOWPLACEMENT selectRect = InteropUtil.GetWindowPlacement(hSelectButton); rect.top = selectRect.Top; rect.bottom = selectRect.Bottom; rect.right = InteropUtil.GetWindowPlacement(fileName).Right; rect.left = rect.right - (m_cancelWidth + m_buttonGap + m_selectWidth); ResizeCustomControl(hWnd, rect, hOkButton, hSelectButton); } }