Hello all, 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...
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 = &myData;
HWND hwnd = (HWND)FindWindow(L"Dialog1",L"Test");
SendMessageA(m_hWnd,WM_COPYDATA,(WPARAM)hwnd,(LPARAM)(LPVOID)&myData);
Dialog1 dlg;
dlg.DoModal();
}
Receiver class:
#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->dwData)
{
case iMessage:
MessageBoxA((HWND)AfxGetInstanceHandle(),(LPCSTR)(LPCTSTR)((DATA*)(pData->lpData))->myData,(LPCSTR)L"Test",MB_OK);
}
return 0;
}
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...