Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 9e543b2

Browse files
committed
Made the WM_DESTROY fix official
The fix for #85, #93, #97 and #123 has been out and vetted by users for quite a while now and so I'm making it the default behavior. Instead of calling SetDestroyHandleBehavior(true) to enable it, it is now enabled by default and can be disabled by calling SetDestroyHandleBehavior(false).
1 parent 83b053e commit 9e543b2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/ScintillaNET/Scintilla.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Scintilla : Control
2626
#region Fields
2727

2828
// WM_DESTROY workaround
29-
private static bool? reparentGlobal;
29+
private static bool? reparentAll;
3030
private bool reparent;
3131

3232
// Static module data
@@ -2261,14 +2261,17 @@ public unsafe void SetKeywords(int set, string keywords)
22612261
/// <summary>
22622262
/// Sets the application-wide behavior for destroying <see cref="Scintilla" /> controls.
22632263
/// </summary>
2264-
/// <param name="reparent">true to reparent Scintilla controls to message-only windows when destroyed rather than actually destroying the control handle; otherwise, false.</param>
2264+
/// <param name="reparent">
2265+
/// true to reparent Scintilla controls to message-only windows when destroyed rather than actually destroying the control handle; otherwise, false.
2266+
/// The default is true.
2267+
/// </param>
22652268
/// <remarks>This method must be called prior to the first <see cref="Scintilla" /> control being created.</remarks>
22662269
public static void SetDestroyHandleBehavior(bool reparent)
22672270
{
22682271
// WM_DESTROY workaround
2269-
if (Scintilla.reparentGlobal == null)
2272+
if (Scintilla.reparentAll == null)
22702273
{
2271-
Scintilla.reparentGlobal = reparent;
2274+
Scintilla.reparentAll = reparent;
22722275
}
22732276
}
22742277

@@ -6020,8 +6023,8 @@ public event EventHandler<EventArgs> ZoomChanged
60206023
public Scintilla()
60216024
{
60226025
// WM_DESTROY workaround
6023-
if (Scintilla.reparentGlobal.HasValue)
6024-
reparent = (bool)Scintilla.reparentGlobal;
6026+
if (Scintilla.reparentAll == null || (bool)Scintilla.reparentAll)
6027+
reparent = true;
60256028

60266029
// We don't want .NET to use GetWindowText because we manage ('cache') our own text
60276030
base.SetStyle(ControlStyles.CacheText, true);

0 commit comments

Comments
 (0)