diff options
-rw-r--r-- | IvyProbe/IvyProbeDlg.cpp | 85 |
1 files 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();
+
+ }
+
+}
|