From 0440889eb6038aaf47668f0f5ea2958c0868bdb7 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:10:51 +0000 Subject: Utilisateur : Fcolin Date : 27/03/02 Heure : 12:29 Archivé dans $/Bus/Test Commentaire: Add file load and save for message (vss 13) --- IvyProbe/IvyProbeDlg.cpp | 85 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/IvyProbe/IvyProbeDlg.cpp b/IvyProbe/IvyProbeDlg.cpp index 3ecc751..f504a1c 100644 --- a/IvyProbe/IvyProbeDlg.cpp +++ b/IvyProbe/IvyProbeDlg.cpp @@ -14,27 +14,6 @@ static char THIS_FILE[] = __FILE__; #endif -const char * CONVSTR( const CString& str ) -{ -#ifdef UNDER_CE - - static char buffer[4096]; - int len = str.GetLength(); - buffer[len] = '\0'; - if ( len ) - { - int err = WideCharToMultiByte( CP_ACP, 0, str, len, buffer, 4096, NULL, NULL ); - if ( err == 0 ) - TRACE(TEXT("Error converting chars %d\n"),GetLastError()); - } - return buffer; -#else - return (LPCSTR) str; -#endif - -} - - CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { @@ -93,11 +72,36 @@ BEGIN_MESSAGE_MAP(CTestDlg, MyDialog) ON_BN_CLICKED(IDC_CLOCK_START, OnClockStart) ON_BN_CLICKED(IDC_CLOCK_FORWARD, OnClockForward) ON_BN_CLICKED(IDC_CLOCK_FAST_FORWARD, OnClockFastForward) - ON_WM_SYSCOMMAND() ON_BN_CLICKED(IDC_CLOCK_RATE, OnClockRate) + ON_WM_SYSCOMMAND() + ON_COMMAND(FILE_LOAD, OnLoad) + ON_COMMAND(FILE_SAVE, OnSave) //}}AFX_MSG_MAP END_MESSAGE_MAP() + + +const char * CONVSTR( const CString& str ) +{ +#ifdef UNDER_CE + + static char buffer[4096]; + int len = str.GetLength(); + buffer[len] = '\0'; + if ( len ) + { + int err = WideCharToMultiByte( CP_ACP, 0, str, len, buffer, 4096, NULL, NULL ); + if ( err == 0 ) + TRACE(TEXT("Error converting chars %d\n"),GetLastError()); + } + return buffer; +#else + return (LPCSTR) str; +#endif + +} + + ///////////////////////////////////////////////////////////////////////////// // CTestDlg message handlers @@ -347,3 +351,40 @@ void CTestDlg::OnClockRate() int count = bus->SendMsg( CONVSTR(buffer) ); WriteMessage( "Sending %d message %s",count,CONVSTR(buffer) ); } + +void CTestDlg::OnLoad() +{ + CString message; + + CFileDialog dialog( TRUE, "txt", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Ivy Messages Files (*.txt)"); + if ( dialog.DoModal() == IDOK ) + { + CStdioFile file( dialog.GetPathName(), CFile::modeRead | CFile::typeText ); + m_msg.ResetContent(); + while ( file.ReadString(message) ) + { + m_msg.AddString( message ); + } + file.Close(); + } + +} + +void CTestDlg::OnSave() +{ + CString message; + + CFileDialog dialog( FALSE, "txt" , NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Ivy Messages Files (*.txt)"); + if ( dialog.DoModal() == IDOK ) + { + CStdioFile file( dialog.GetPathName(), CFile::modeCreate | CFile::modeWrite | CFile::typeText ); + for (int i=0;i < m_msg.GetCount();i++) + { + m_msg.GetLBText( i, message ); + file.WriteString(message + "\n"); + } + file.Close(); + + } + +} -- cgit v1.1