Since i'm not defining this class inside the Header file i'm not able to access any controls and its values.
Previously i had as like below
//strSocketData is a control variable.
How can i access it in my "ReceiveMessage" method.
UINT RecieveMessage( LPVOID pParam )
//Disclaimer: It's not at all safe to pass around MFC objects. Instead you can pass around HWND's which is safe.
CYourDlg* pYourDlg = reinterpret_cast< CYourDlg* >( pParam );
pYourDlg->strSocketData.SetWindowText( pYourDlg->strResult );
SocketThread = AfxBeginThread(ReceiveMessage,this);
You mentioned that it is not safe is there anyother alternate.
No it's not at all thread safe to pass around MFC objects. Instead pass the HWND of your dialog. Then use SetDlgItemText to set the text for the item.
SetDlgItemText( hDialog, IDD_DIALOGCONTROL_ID, _T( "This is thread safe" ));
Well you cannot retrieve the strResult parameter too. To get around this store the buffer of strResult inside another pointer. Put both the handle to the dialog and the pointer to the buffer inside the struct and then pass this struct object to the thread.