Index: Core/Common/src/Core.Common.Controls/Forms/EnhancedButton.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Controls/Forms/EnhancedButton.cs (revision 0) +++ Core/Common/src/Core.Common.Controls/Forms/EnhancedButton.cs (revision 0b486f2d9e94607ca10a9669fece160b9c05cd4e) @@ -0,0 +1,55 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Windows.Forms; + +namespace Core.Common.Controls.Forms +{ + /// + /// Button that also responds to clicks when its containing form does not have input focus. + /// + public class EnhancedButton : Button + { + const uint WM_LBUTTONDOWN = 0x201; + const uint WM_LBUTTONUP = 0x202; + + protected override void WndProc(ref Message message) + { + if (message.Msg == WM_LBUTTONUP) + { + SimulateMouseClick(ref message); + } + else + { + base.WndProc(ref message); + } + } + + private void SimulateMouseClick(ref Message m) + { + m.Msg = (int) WM_LBUTTONDOWN; + base.WndProc(ref m); + + m.Msg = (int) WM_LBUTTONUP; + base.WndProc(ref m); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Controls.Test/Core.Common.Controls.Test.csproj =================================================================== diff -u -rfdcad55802f3fc8091d69f70c6aa1a16a0ffc2f9 -r0b486f2d9e94607ca10a9669fece160b9c05cd4e --- Core/Common/test/Core.Common.Controls.Test/Core.Common.Controls.Test.csproj (.../Core.Common.Controls.Test.csproj) (revision fdcad55802f3fc8091d69f70c6aa1a16a0ffc2f9) +++ Core/Common/test/Core.Common.Controls.Test/Core.Common.Controls.Test.csproj (.../Core.Common.Controls.Test.csproj) (revision 0b486f2d9e94607ca10a9669fece160b9c05cd4e) @@ -15,10 +15,10 @@ - - - - + + + + Index: Core/Common/test/Core.Common.Controls.Test/Forms/EnhancedButtonTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Controls.Test/Forms/EnhancedButtonTest.cs (revision 0) +++ Core/Common/test/Core.Common.Controls.Test/Forms/EnhancedButtonTest.cs (revision 0b486f2d9e94607ca10a9669fece160b9c05cd4e) @@ -0,0 +1,39 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Windows.Forms; +using Core.Common.Controls.Forms; +using NUnit.Framework; + +namespace Core.Common.Controls.Test.Forms +{ + [TestFixture] + public class EnhancedButtonTest + { + [Test] + public void Constructor_ExpectedValues() + { + var button = new EnhancedButton(); + + Assert.IsInstanceOf