diff --git a/PInvoke/User32/BasicMessageWindow.cs b/PInvoke/User32/BasicMessageWindow.cs index 8026dc8d..2905114e 100644 --- a/PInvoke/User32/BasicMessageWindow.cs +++ b/PInvoke/User32/BasicMessageWindow.cs @@ -41,6 +41,12 @@ namespace Vanara.PInvoke /// Finalizes an instance of the class. ~BasicMessageWindow() => Dispose(false); + /// Occurs when the window handle has been created. + public event EventHandler HandleCreated; + + /// Occurs when the window handle has been destroyed. + public event EventHandler HandleDestroyed; + /// Gets the handle. /// The handle. public HWND Handle => hwnd; @@ -92,6 +98,10 @@ namespace Vanara.PInvoke { if (msg == (uint)WindowMessage.WM_NCCREATE) return (IntPtr)1; + if (msg == (uint)WindowMessage.WM_CREATE) + HandleCreated?.Invoke(this, EventArgs.Empty); + if (msg == (uint)WindowMessage.WM_DESTROY) + HandleDestroyed?.Invoke(this, EventArgs.Empty); return !weakSelfRef.IsAlive || weakSelfRef.Target is null || MessageFilter is null || !MessageFilter.Invoke(hwnd, msg, wParam, lParam, out IntPtr lRet) ? DefWindowProc(hwnd, msg, wParam, lParam) : lRet;