Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to change window's class style using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633588(v=vs.85).aspx" rel="nofollow"><code>SetClassLong</code></a></p> <p>There is example in <a href="/questions/tagged/c%23" class="post-tag" title="show questions tagged 'c#'" rel="tag">c#</a>, but idea is still the same:</p> <pre><code>public partial class Form1 : Form { protected override CreateParams CreateParams { get { var cp = base.CreateParams; //cp.ClassStyle |= 0x200; // note this is off return cp; } } public Form1() { InitializeComponent(); } // here button is being disabled private void Form1_Load(object sender, EventArgs e) { HandleRef handle = new HandleRef(null, this.Handle); var cp = CreateParams; cp.ClassStyle = cp.ClassStyle | (0x200); IntPtr style = new IntPtr(cp.ClassStyle); var classLong = Form1.SetClassLong(handle, (int)ClassLongFlags.GCL_STYLE, style); } // here is being enabled private void Form1_DoubleClick(object sender, EventArgs e) { HandleRef handle = new HandleRef(null, this.Handle); var cp = CreateParams; cp.ClassStyle = cp.ClassStyle &amp; (~0x200); IntPtr style = new IntPtr(cp.ClassStyle); var classLong = Form1.SetClassLong(handle, (int)ClassLongFlags.GCL_STYLE, style); } } </code></pre> <p><code>SetClassLong</code>, <code>ClassLongFlags</code> can be found here <a href="http://www.pinvoke.net/" rel="nofollow">http://www.pinvoke.net/</a> </p> <p>Here is <a href="/questions/tagged/c%2b%2b-cli" class="post-tag" title="show questions tagged 'c++-cli'" rel="tag">c++-cli</a> version, without pinvoke.</p> <pre><code>#include &lt;windows.h&gt; #define GCL_STYLE -26 using namespace System::Windows::Forms; using namespace System::Runtime::InteropServices; using namespace System; public ref class Form1 : public Form { public: Form1() { InitializeComponent(); this-&gt;Load += gcnew EventHandler( this, &amp;Form1::Form1_Load); this-&gt;DoubleClick += gcnew EventHandler( this, &amp;Form1::Form1_DoubleClick); } protected: virtual property System::Windows::Forms::CreateParams^ CreateParams { System::Windows::Forms::CreateParams^ get() override { System::Windows::Forms::CreateParams^ cp = Form::CreateParams; //cp-&gt;ClassStyle |= 0x200; //CP_NOCLOSE_BUTTON return cp; } } private: void Form1_Load(Object^ sender, EventArgs^ e) { HandleRef^ handle = gcnew HandleRef(nullptr, this-&gt;Handle); System::Windows::Forms::CreateParams^ cp = Form::CreateParams; cp-&gt;ClassStyle = cp-&gt;ClassStyle | (0x200); IntPtr^ style = gcnew IntPtr(cp-&gt;ClassStyle); ::SetClassLong( (HWND)this-&gt;Handle.ToPointer(), (int)GCL_STYLE, (LONG)style-&gt;ToInt32()); } // here is being enabled // possibly, it is gonna be your `foo` void Form1_DoubleClick(Object^ sender, EventArgs^ e) { HandleRef^ handle = gcnew HandleRef(nullptr, this-&gt;Handle); System::Windows::Forms::CreateParams^ cp = Form::CreateParams; cp-&gt;ClassStyle = cp-&gt;ClassStyle &amp; (~0x200); IntPtr^ style = gcnew IntPtr(cp-&gt;ClassStyle); ::SetClassLong( (HWND)this-&gt;Handle.ToPointer(), (int)GCL_STYLE, (LONG)style-&gt;ToInt32()); } }; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload