public VisiCalcFormBase() { _formSystemLayer = new FormSystemLayer(this, new NuGenWndProcDelegate(this.RealWndProc)); this.Controls.Add(_formSystemLayer); _formSystemLayer.Visible = false; DecideOpacitySetting(); this.ResumeLayout(false); }
private FormSystemLayer FindFormSystemLayer(Form host) { if (host != null) { Control.ControlCollection controls = host.Controls; for (Int32 i = 0; i < controls.Count; ++i) { FormSystemLayer formSystemLayer = controls[i] as FormSystemLayer; if (formSystemLayer != null) { return(formSystemLayer); } } } return(null); }
/// <summary> /// Manages some special handling of window messages. /// </summary> /// <param name="m"></param> /// <returns>true if the message was handled, false if the caller should handle the message.</returns> public Boolean HandleParentWndProc(ref Message m) { Boolean returnVal = true; switch (m.Msg) { case WinUser.WM_NCPAINT: { goto default; } case WinUser.WM_NCACTIVATE: { if (_forceActiveTitleBar && m.WParam == IntPtr.Zero) { if (_ignoreNcActivate > 0) { --_ignoreNcActivate; goto default; } else if (Form.ActiveForm != _host || // Gets rid of: if you have the form active, then click on the desktop --> desktop refreshes !_host.Visible) // Gets rid of: desktop refresh on exit { goto default; } else { _parentWndProc(ref m); User32.SendMessage( _host.Handle , WinUser.WM_NCACTIVATE , new IntPtr(1) , IntPtr.Zero ); break; } } else { goto default; } } case WinUser.WM_ACTIVATE: { goto default; } case WinUser.WM_ACTIVATEAPP: { _parentWndProc(ref m); } // Check if the app is being deactivated if (_forceActiveTitleBar && m.WParam == IntPtr.Zero) { // If so, put our titlebar in the inactive state User32.PostMessage(_host.Handle, WinUser.WM_NCACTIVATE, IntPtr.Zero, IntPtr.Zero); ++_ignoreNcActivate; } if (m.WParam == new IntPtr(1)) { foreach (Form childForm in _host.OwnedForms) { FormSystemLayer childFormEx = FindFormSystemLayer(childForm); if (childFormEx != null) { if (childFormEx.ForceActiveTitleBar && childForm.IsHandleCreated) { User32.PostMessage( childForm.Handle , WinUser.WM_NCACTIVATE , new IntPtr(1) , IntPtr.Zero ); } } } FormSystemLayer ownerEx = FindFormSystemLayer(_host.Owner); if (ownerEx != null) { if (ownerEx.ForceActiveTitleBar && _host.Owner.IsHandleCreated) { User32.PostMessage( _host.Owner.Handle , WinUser.WM_NCACTIVATE , new IntPtr(1) , IntPtr.Zero ); } } } break; default: returnVal = false; break; } GC.KeepAlive(_host); return(returnVal); }
public VisiCalcFormBase() { _formSystemLayer = new FormSystemLayer(this, new NuGenWndProcDelegate(this.RealWndProc)); this.Controls.Add(_formSystemLayer); _formSystemLayer.Visible = false; DecideOpacitySetting(); this.ResumeLayout(false); }