title: MFC click and move/drag dialog window
body: <p>I am currently working on finishing some code handed off to me. It was written in MFC in Visual Studio 2005 years ago, was put on hold, and now is brought to me. </p>
  
  <p>While I know C++, I have spent the last ~2 months studying the code and learning MFC and it's starting to come together.</p>
  
  <p>The GUI for the code is an SWF flash file embedded in an invisible dialog window. I do not have the source code for the SWF file so will probably, in the future, redo it in WPF or something. I have the WMMode set to "Window" because in Transparent/Opaque mode it doesn't display properly, where it flashes/blinks everytime a mouse event is captured. </p>
  
  <p>Anyhow, in Win XP/Vista, clicking and dragging the flash control works. In windows 7/8.1, it won't move. </p>
  
  <p>Happy to provide any and all info needed. I'm still a little overwhelmed by MFC dialogs so unsure what you'd all like to see. </p>
  
  <p>I found this question: <a href="https://stackoverflow.com/questions/13477228/moving-window-by-click-drag-on-a-control">Moving window by click-drag on a control</a></p>
  
  <p>Which looks like it solves a lot of the issue. However, I don't want the whole control to be clickable like this, only the top part. Unfortunately, in the MS Resource view, the ActiveX control is blank as the SWF is only loaded at runtime; I've tried to find resources for this kind of thing but it's very difficult as I am unsure of the technical terms to use. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have attempted this by creating a very simple MFC app that has a Static Text control and nothing else. I am trying to get it to work by clicking on the static text (though I may be painting myself into a corner as it does not have a built-in lButtonDown event). </p>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>class MyDialog : public CDialog
  {
  public:
      MyDialog(CWnd* pParent = NULL) : CDialog(MyDialog::IDD, pParent)
      {    }
      // Dialog Data, name of dialog form
      enum{ IDD = INTERFACE1 };
  protected:
      virtual void DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); }
      //Called right after constructor. Initialize things here.
      virtual BOOL OnInitDialog()
      {
          CDialog::OnInitDialog();
          pText = (CStatic *)GetDlgItem(ID_TEXT);
  
          pText-&gt;SetWindowTextW(_T("Hello World!"));
  
          return true;
      }
  
      afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  
  private:
      CStatic * pText;
  
  public:
      DECLARE_MESSAGE_MAP()
  };
  
  BEGIN_MESSAGE_MAP(MyDialog, CDialog)
      ON_WM_LBUTTONDOWN()
  END_MESSAGE_MAP()
  </code></pre>
  
  <p>Overridden Method:</p>
  
  <pre><code>afx_msg void MyDialog::OnLButtonDown(UINT nFlags, CPoint point)
  {
      CWnd::OnNcLButtonDown(HTCAPTION, point);
  
  }
  </code></pre>
  
  <p>I have also tried setting nFlags to 0x2, calling OnLButtonDown (as opposed to onNcLButtonDown), various other things. The message fires but the window does not move (it does move from the title bar, as normal). What am I missing?</p>