1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| StateMachine *stateMachine1 = new StateMachine;
Dialog::Dialog(CWnd* pParent) : CDialog(Dialog::IDD, pParent)
{
}
void Dialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Dialog, CDialog)
...
ON_EN_CHANGE(IDC_EDIT_LOG, &Dialog::OnEnChangeEditLog)
ON_MESSAGE(WM_PROC_CONTROL, OnProcControl) // Le proc control qui communique avec une DLL
ON_MESSAGE(WM_PROC_CONTROL2, OnProcControl2)
END_MESSAGE_MAP()
LRESULT Dialog::OnProcControl(WPARAM aParam, LPARAM aParam)
{
CString strTmp;
const int MAX_RECEIVE = 1024; // Nombre maximal d'octets de tampon de réception
TCHAR szReceive[MAX_RECEIVE];
memset ( szReceive, 0, sizeof(szReceive) );
// Reçu via l'application xxx à travers la DLL
int nRecCount = RecieveCommand( szReceive, sizeof(szReceive) ); ////////////////////// Information reçu par la DLL que j'affiche ensuite dans mon Log //////////////////////
CString strTxtLog
GetDlgItemText(IDC_EDIT_LOG, strTxtLog);
if( 0 < nRecCount )
{
strTmp.Format( _T("*[Receive]%s%s"), szReceive, SZ_CRLF );
strTxtLog += strTmp;
}
else
{
strTmp.Format( _T("*[Receive]Error[No received data.)%s"), SZ_CRLF );
strTxtLog += strTmp;
}
SetDlgText( IDC_EDIT_LOG, strTxtLog );
((CEdit*)GetDlgItem(IDC_EDIT_LOG))->SetSel( strTxtLog.GetLength(), strTxtLog.GetLength() );
////////////////////// Transmettre strTxtLog à mon thread //////////////////////
return (LRESULT)0;
}
LRESULT Dialog::OnProcControl2(WPARAM wParam, LPARAM lParam)
{
...
}
void Dialog::OnClickedStart
{
...
AfxBeginThread(MyThread,This);
}
UINT MyThread(LPVOID Param)
{
...
stateMachine1->Etats(0);
...
} |
Partager