mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user