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

Commit

Permalink
Made the WM_DESTROY fix official
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jacobslusser committed Jul 24, 2016
1 parent 83b053e commit 9e543b2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/ScintillaNET/Scintilla.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Scintilla : Control
#region Fields

// WM_DESTROY workaround
private static bool? reparentGlobal;
private static bool? reparentAll;
private bool reparent;

// Static module data
Expand Down Expand Up @@ -2261,14 +2261,17 @@ public unsafe void SetKeywords(int set, string keywords)
/// <summary>
/// Sets the application-wide behavior for destroying <see cref="Scintilla" /> controls.
/// </summary>
/// <param name="reparent">true to reparent Scintilla controls to message-only windows when destroyed rather than actually destroying the control handle; otherwise, false.</param>
/// <param name="reparent">
/// true to reparent Scintilla controls to message-only windows when destroyed rather than actually destroying the control handle; otherwise, false.
/// The default is true.
/// </param>
/// <remarks>This method must be called prior to the first <see cref="Scintilla" /> control being created.</remarks>
public static void SetDestroyHandleBehavior(bool reparent)
{
// WM_DESTROY workaround
if (Scintilla.reparentGlobal == null)
if (Scintilla.reparentAll == null)
{
Scintilla.reparentGlobal = reparent;
Scintilla.reparentAll = reparent;
}
}

Expand Down Expand Up @@ -6020,8 +6023,8 @@ public int Zoom
public Scintilla()
{
// WM_DESTROY workaround
if (Scintilla.reparentGlobal.HasValue)
reparent = (bool)Scintilla.reparentGlobal;
if (Scintilla.reparentAll == null || (bool)Scintilla.reparentAll)
reparent = true;

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

0 comments on commit 9e543b2

Please sign in to comment.