diff --git a/src/modules/previewpane/common/controls/FormHandlerControl.cs b/src/modules/previewpane/common/controls/FormHandlerControl.cs
index 7c5de79574..b7b055852d 100644
--- a/src/modules/previewpane/common/controls/FormHandlerControl.cs
+++ b/src/modules/previewpane/common/controls/FormHandlerControl.cs
@@ -14,6 +14,12 @@ namespace Common
///
public abstract class FormHandlerControl : Form, IPreviewHandlerControl
{
+ ///
+ /// Needed to make the form a child window.
+ ///
+ private static int gwlStyle = -16;
+ private static int wsChild = 0x40000000;
+
///
/// Holds the parent window handle.
///
@@ -150,6 +156,12 @@ namespace Common
[DllImport("user32.dll", CharSet = CharSet.Auto)]
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);
+
///
/// Update the Form Control window with the passed rectangle.
///
@@ -158,6 +170,13 @@ namespace Common
{
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);
this.Bounds = windowBounds;
});