title: How to get a HWND handle out of a System.Windows.Forms.Form
body: <p>Given the form</p>
  
  <pre><code>System.Windows.Forms::Form Form1;
  </code></pre>
  
  <p>and the window handle</p>
  
  <pre><code>HWND hWnd;
  </code></pre>
  
  <p>How can I set hWnd to the Handle property of Form1 that does truly exist as a public property that "Gets the window handle that the control is bound to. (Inherited from Control.)" according to the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx" rel="noreferrer">Microsoft documentation of System.Windows.Forms::Form</a>? In the constructor of my Form Form1, I've tried</p>
  
  <pre><code>hWnd = this.Handle;
  </code></pre>
  
  <p>but the compiler complains:</p>
  
  <p>error C2228: left of '.Handle' must have class/struct/union type is 'MyNamespace::Form1 ^const ' did you intend to use '->' instead?</p>
  
  <p>So I try </p>
  
  <pre><code>hWnd = this-&gt;Handle;
  </code></pre>
  
  <p>and just </p>
  
  <pre><code>hWnd = Handle; // Since I'm in the Form
  </code></pre>
  
  <p>and then the compiler says:</p>
  
  <p>error C2440: '=' : cannot convert from 'System::IntPtr' to 'HWND' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called</p>