[PreviewPane]Fix location and scaling issues with different DPI (#31802)

* [PreviewPane] Monaco Previewer: await initial position, size update + use recieved coordinates

* Fixing size and position issue for all file explorer previewers
This commit is contained in:
Laszlo Nemeth
2024-03-20 15:28:43 +01:00
committed by GitHub
parent f5797a065a
commit 58e598815c
13 changed files with 85 additions and 15 deletions

View File

@@ -75,7 +75,7 @@ namespace Common
/// <inheritdoc />
public void SetRect(Rectangle windowBounds)
{
this.UpdateWindowBounds(parentHwnd);
this.UpdateWindowBounds(parentHwnd, windowBounds);
}
/// <inheritdoc />
@@ -88,7 +88,7 @@ namespace Common
public void SetWindow(IntPtr hwnd, Rectangle rect)
{
this.parentHwnd = hwnd;
this.UpdateWindowBounds(hwnd);
this.UpdateWindowBounds(hwnd, rect);
}
/// <inheritdoc />
@@ -118,7 +118,7 @@ namespace Common
/// <summary>
/// Update the Form Control window with the passed rectangle.
/// </summary>
public void UpdateWindowBounds(IntPtr hwnd)
public void UpdateWindowBounds(IntPtr hwnd, Rectangle newBounds)
{
// We must set the WS_CHILD style to change the form to a control within the Explorer preview pane
int windowStyle = NativeMethods.GetWindowLong(Handle, gwlStyle);
@@ -129,12 +129,16 @@ namespace Common
NativeMethods.SetParent(Handle, hwnd);
RECT s = default(RECT);
NativeMethods.GetClientRect(hwnd, ref s);
if (Bounds.Right != s.Right || Bounds.Bottom != s.Bottom || Bounds.Left != s.Left || Bounds.Top != s.Top)
if (newBounds.IsEmpty)
{
Bounds = s.ToRectangle();
RECT s = default(RECT);
NativeMethods.GetClientRect(hwnd, ref s);
newBounds = new Rectangle(s.Left, s.Top, s.Right - s.Left, s.Bottom - s.Top);
}
if (Bounds.Right != newBounds.Right || Bounds.Bottom != newBounds.Bottom || Bounds.Left != newBounds.Left || Bounds.Top != newBounds.Top)
{
Bounds = newBounds;
}
}
}