title: crash on ShowWindow()
body: <p>I am developing a Notepad++ plugin.</p>
  
  <p>I have a simple dialog box, which is created using <code>CreateDialogParam()</code>. It is initially hidden.</p>
  
  <p>After a menu click,  I call <code>ShowWindow()</code> with <code>SW_SHOW</code> on its handle, which results in this exception:</p>
  
  <p><code>c000041d</code></p>
  
  <p>Upon debugging , I found that these two messages are sent to my dialog just before crash
  <code>WM_SHOWWINDOW</code><br>
  <code>WM_WINDOWPOSCHANGING</code></p>
  
  <p>Both of them, I am not handling. Here is my dlgproc code. Any idea why it would happen ?</p>
  
  <pre><code>BOOL CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
  {
      switch (message) 
      {
          case WM_INITDIALOG :
          {
              // Get the additional init data
              StaticDialog *pStaticDlg = (StaticDialog *)(lParam);
  
              // Store the handle in the object
              pStaticDlg-&gt;_hSelf = hwnd;
  
  
              ::SetWindowLongPtr(hwnd, GWL_USERDATA, (long)lParam);
  
              // Store the co-ordinates in the object
              ::GetWindowRect(hwnd, &amp;(pStaticDlg-&gt;_rc));
  
              // Forward the message for further processing
              pStaticDlg-&gt;run_dlgProc(message, wParam, lParam);
  
              // TRUE if it processed the message
              return TRUE;
          }
  
          default :
          {
              // Retrieve the user data
              StaticDialog *pStaticDlg = (StaticDialog *)(::GetWindowLongPtr(hwnd, GWL_USERDATA));
              if (!pStaticDlg)
                  return FALSE;
  
              // Send the message for further processing
              return pStaticDlg-&gt;run_dlgProc(message, wParam, lParam);
  
              // return FALSE if it processed the message
          }
      }
  }
  
  
  
  BOOL CALLBACK MarkDownViewDialog::run_dlgProc( UINT Message, WPARAM wParam, LPARAM lParam)
  {
      switch (Message) 
      {
          case WM_INITDIALOG:
          {
              EmbedBrowserObject(this-&gt;_hSelf);
              DisplayHTMLPage(this-&gt;_hSelf,L"http://www.microsoft.com");
              DisplayHTMLStr(this-&gt;_hSelf, L"&lt;H2&gt;&lt;CENTER&gt;HTML string test&lt;/CENTER&gt;&lt;/H2&gt;&lt;P&gt;&lt;FONT COLOR=RED&gt;This is a &lt;U&gt;HTML string&lt;/U&gt; in memory.&lt;/FONT&gt;");
  
              break;
          }
  
  
  
          default:
              break;
      }
  
      return FALSE;
  }
  </code></pre>
  
  <p>The dialog box is created through plugin mechanism of Notpead++. I am putting the source code from its file StaticDialog.cpp. The control goes through <code>else</code> block in code below.</p>
  
  <pre><code>void StaticDialog::create(int dialogID, bool isRTL, bool isModeles)
  {
      if (isRTL)
      {
          DLGTEMPLATE *pMyDlgTemplate = NULL;
          HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &amp;pMyDlgTemplate);
          _hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, (DLGPROC)dlgProc, (LPARAM)this);
          ::GlobalFree(hMyDlgTemplate);
      }
      else
          _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, (DLGPROC)dlgProc, (LPARAM)this);
      //int i=GetLastError();
  
      if (!_hSelf)
      {
          //systemMessage(_T("StaticDialog"));
          return;
      }
  
      if (isModeles) {
          _isModeles = isModeles;
          ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf);
      }
  }
  </code></pre>
  
  <p>My entire solution source code is hosted here:
  <a href="https://github.com/madhur/Npp-Markdown-Viewer" rel="nofollow">https://github.com/madhur/Npp-Markdown-Viewer</a></p>
  
  <h1>Issue Resolution</h1>
  
  <p>Here is what I have done to troubleshoot the problem:  </p>
  
  <ul>
  <li><p>Created a Win32 project in which I create a dialog box and put exactly same source code to embed browser control in WM_INITDIALOG and it works. This Win32 project links with the same static library, which the original source code is linking with. This is the source of the sample project mail file:<br>
  <a href="https://github.com/madhur/Npp-Markdown-Viewer/blob/master/dll/example/example.c" rel="nofollow">https://github.com/madhur/Npp-Markdown-Viewer/blob/master/dll/example/example.c</a></p></li>
  <li><p>The static library I referenced above, is nothing but it contains functions to embed browser control in HWND and to render either an URL or string. I have taken the source from here: <a href="http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4379" rel="nofollow">http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4379</a>
  This is the source of static library main file:<br>
  <a href="https://github.com/madhur/Npp-Markdown-Viewer/blob/master/dll/dll.c" rel="nofollow">https://github.com/madhur/Npp-Markdown-Viewer/blob/master/dll/dll.c</a></p></li>
  <li><p>If I comment this single line, the plugin works, basically it loads the dialog box without the Browser control in it:</p>
  
  <p>EmbedBrowserObject(this->_hSelf);</p></li>
  <li><p>The actual exception in Visual Studio is raised on this line:</p></li>
  </ul>
  
  <p>return pStaticDlg->run_dlgProc(message, wParam, lParam);</p>