title: Problem in Communication between two dialog boxes through WM_COPYDATA?
body: <p>Friends its really giving me a great head ache about the problem I am facing for the couple of days...Its simple...I want to communicate between two/more  dialog boxes for example if there is a variable CString test..I want this test variable to be common for the dialogs/classes(considering each dialog having separate classes)...I tried lot methods, everything failed..atlast I tried this WM_COPYDATA method...even now, am not achieve what i wanted to do...</p>
  
  <pre><code>Sender Class:
  
  #define ORGININFO 1
  
  typedef struct ShareMessage
  {
      CString mydata;
      int myValue;
  }MYDATA;
  
  void CCopyDataDlg::OnBnClickedOk()
  {
      // TODO: Add your control notification handler code here
      MYDATA myData;
      COPYDATASTRUCT cData;
  
      myData.mydata.SetString(L"Rakesh");
  
      cData.dwData = ORGININFO;
      cData.cbData = sizeof(myData);
      cData.lpData = &amp;myData;
  
      HWND hwnd  = (HWND)FindWindow(L"Dialog1",L"Test");
  
  
  
      SendMessageA(m_hWnd,WM_COPYDATA,(WPARAM)hwnd,(LPARAM)(LPVOID)&amp;myData);
  
  
      Dialog1 dlg;
      dlg.DoModal();
  
  }
  </code></pre>
  
  <p>Receiver class:</p>
  
  <pre><code>#define iMessage 1
  
  typedef struct MyDatas
  {
      CString myData;
      int myint;
  }DATA;
  PCOPYDATASTRUCT pData;
  
  
  LRESULT Dialog1::WindowProc(UINT message,WPARAM wParam,LPARAM lparam)
  {
  
      if(WM_COPYDATA != NULL)
          pData = (PCOPYDATASTRUCT)lparam;
          switch(pData-&gt;dwData)
          {
          case iMessage:
              MessageBoxA((HWND)AfxGetInstanceHandle(),(LPCSTR)(LPCTSTR)((DATA*)(pData-&gt;lpData))-&gt;myData,(LPCSTR)L"Test",MB_OK);
  
          }
      return 0;
  }
  </code></pre>
  
  <p>in the above I dont know what is the mistake I am doing but its not receiving the data from the CCopyDialog class...Please help me with this...</p>