diff options
author | fcolin | 2007-02-01 13:10:51 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 13:10:51 +0000 |
commit | 9d870f8d5047e3455d12b2f933a784e7b5461654 (patch) | |
tree | 2194634a16055e49e4ac4d5cadfc8fd3775c3ca1 /Bus | |
parent | da138b0c4e7b5b030bd7039ea1c66e728a9eaadd (diff) | |
download | ivy-cplusplus-9d870f8d5047e3455d12b2f933a784e7b5461654.zip ivy-cplusplus-9d870f8d5047e3455d12b2f933a784e7b5461654.tar.gz ivy-cplusplus-9d870f8d5047e3455d12b2f933a784e7b5461654.tar.bz2 ivy-cplusplus-9d870f8d5047e3455d12b2f933a784e7b5461654.tar.xz |
Utilisateur : Fcolin Date : 27/03/02 Heure : 12:29 Archivé dans $/Bus/Test Commentaire: Add file load and save for message (vss 13)
Diffstat (limited to 'Bus')
-rw-r--r-- | Bus/IvyProbe/IvyProbeDlg.cpp | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/Bus/IvyProbe/IvyProbeDlg.cpp b/Bus/IvyProbe/IvyProbeDlg.cpp index 3ecc751..f504a1c 100644 --- a/Bus/IvyProbe/IvyProbeDlg.cpp +++ b/Bus/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();
+
+ }
+
+}
|