mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
Setting WS_CHILD on preview handler (#3048)
This commit is contained in:
parent
071ea1dc97
commit
ccfc4d68f3
@ -14,6 +14,12 @@ namespace Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class FormHandlerControl : Form, IPreviewHandlerControl
|
public abstract class FormHandlerControl : Form, IPreviewHandlerControl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Needed to make the form a child window.
|
||||||
|
/// </summary>
|
||||||
|
private static int gwlStyle = -16;
|
||||||
|
private static int wsChild = 0x40000000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds the parent window handle.
|
/// Holds the parent window handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -150,6 +156,12 @@ namespace Common
|
|||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||||
private static extern IntPtr GetFocus();
|
private static extern IntPtr GetFocus();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the Form Control window with the passed rectangle.
|
/// Update the Form Control window with the passed rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -158,6 +170,13 @@ namespace Common
|
|||||||
{
|
{
|
||||||
this.InvokeOnControlThread(() =>
|
this.InvokeOnControlThread(() =>
|
||||||
{
|
{
|
||||||
|
// We must set the WS_CHILD style to change the form to a control within the Explorer preview pane
|
||||||
|
int windowStyle = GetWindowLong(this.Handle, gwlStyle);
|
||||||
|
if ((windowStyle & wsChild) == 0)
|
||||||
|
{
|
||||||
|
SetWindowLong(this.Handle, gwlStyle, windowStyle | wsChild);
|
||||||
|
}
|
||||||
|
|
||||||
SetParent(this.Handle, this.parentHwnd);
|
SetParent(this.Handle, this.parentHwnd);
|
||||||
this.Bounds = windowBounds;
|
this.Bounds = windowBounds;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user