diff options
-rw-r--r-- | Bus/IvyProbe/IvyProbeDlg.cpp | 158 |
1 files changed, 68 insertions, 90 deletions
diff --git a/Bus/IvyProbe/IvyProbeDlg.cpp b/Bus/IvyProbe/IvyProbeDlg.cpp index 9cd53c3..ff339c1 100644 --- a/Bus/IvyProbe/IvyProbeDlg.cpp +++ b/Bus/IvyProbe/IvyProbeDlg.cpp @@ -63,7 +63,7 @@ END_MESSAGE_MAP() // CTestDlg dialog
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CTestDlg::IDD, pParent)
+ : ETSLayoutDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
m_busnumber = "";
@@ -76,10 +76,10 @@ CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/) void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialog::DoDataExchange(pDX);
+ ETSLayoutDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
- DDX_Control(pDX, IDC_BIND, m_bind);
- DDX_Control(pDX, IDC_MSG, m_msgToSend);
+ DDX_Control(pDX, IDC_REGEXP, m_expr);
+ DDX_Control(pDX, IDC_MSG, m_msg);
DDX_Control(pDX, IDC_TEXT, m_text);
DDX_Control(pDX, IDC_SLIDER7, m_slider7);
DDX_Control(pDX, IDC_SLIDER6, m_slider6);
@@ -93,16 +93,14 @@ void CTestDlg::DoDataExchange(CDataExchange* pDX) //}}AFX_DATA_MAP
}
-BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
+BEGIN_MESSAGE_MAP(CTestDlg, ETSLayoutDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_START, OnStart)
- ON_WM_VSCROLL()
- ON_EN_VSCROLL(IDC_MSG, OnVscrollMsg)
ON_WM_CLOSE()
- ON_EN_VSCROLL(IDC_BIND, OnVscrollBind)
+ ON_BN_CLICKED(IDC_SEND, OnSend)
+ ON_BN_CLICKED(IDC_BIND, OnBind)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -111,7 +109,7 @@ END_MESSAGE_MAP() BOOL CTestDlg::OnInitDialog()
{
- CDialog::OnInitDialog();
+ ETSLayoutDialog::OnInitDialog();
// Add "About..." menu item to system menu.
@@ -136,6 +134,37 @@ BOOL CTestDlg::OnInitDialog() SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
+ // define the Layout
+ CreateRoot( VERTICAL )
+ << ( pane( HORIZONTAL, ABSOLUTE_VERT )
+ << item ( IDC_BUSNUMBER, GREEDY )
+ << item ( IDC_START, NORESIZE )
+ )
+ << item ( IDC_TEXT, GREEDY )
+ << ( pane( HORIZONTAL, ABSOLUTE_VERT )
+ << item( paneNull, GREEDY )
+ << item( IDC_SLIDER0, NORESIZE )
+ << item( IDC_SLIDER1, NORESIZE )
+ << item( IDC_SLIDER2, NORESIZE )
+ << item( IDC_SLIDER3, NORESIZE )
+ << item( IDC_SLIDER4, NORESIZE )
+ << item( IDC_SLIDER5, NORESIZE )
+ << item( IDC_SLIDER6, NORESIZE )
+ << item( IDC_SLIDER7, NORESIZE )
+ << item( paneNull, GREEDY )
+ )
+ << ( pane( HORIZONTAL, ABSOLUTE_VERT )
+ << item( IDC_STATIC_MSG, NORESIZE )
+ << item( IDC_MSG, GREEDY )
+ << item( IDC_SEND, NORESIZE )
+ )
+ << ( pane( HORIZONTAL, ABSOLUTE_VERT )
+ << item( IDC_STATIC_BIND, NORESIZE )
+ << item( IDC_REGEXP, GREEDY )
+ << item( IDC_BIND, NORESIZE )
+ );
+ UpdateLayout ();
+
// TODO: Add extra initialization here
m_slider0.SetRange( 0, 127);
m_slider1.SetRange( 0, 127);
@@ -179,38 +208,11 @@ void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam) }
else
{
- CDialog::OnSysCommand(nID, lParam);
+ ETSLayoutDialog::OnSysCommand(nID, lParam);
}
}
-// If you add a minimize button to your dialog, you will need the code below
-// to draw the icon. For MFC applications using the document/view model,
-// this is automatically done for you by the framework.
-
-void CTestDlg::OnPaint()
-{
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
-}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
@@ -309,39 +311,7 @@ void CTestDlg::WriteMessage(const CString & text) m_text.SetSel( -1, -1, FALSE );
m_text.ReplaceSel( text );
}
-void CTestDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
-{
- // TODO: Add your message handler code here and/or call default
- CSliderCtrl *slider = (CSliderCtrl *)pScrollBar;
- CString text;
- CString value;
- slider->GetWindowText( text );
- value.Format("%d",slider->GetPos());
- text += value;
- TRACE("%s\n",(LPCSTR)text );
- bus->SendMsg( text );
- CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
-}
-void CTestDlg::OnVscrollMsg()
-{
- // TODO: Add your control notification handler code here
- char buffer[200];
- int line = m_msgToSend.GetFirstVisibleLine( ) -1 ;
- if ( line >= 0 )
- {
- int len = m_msgToSend.GetLine( line , buffer, sizeof(buffer)-1);
- if ( len )
- {
- buffer[len] = '\0';
- TRACE("IDC MSG Scroll %d len= %d %s\n",line,len, buffer);
- int count = bus->SendMsg( buffer );
- CString mess;
- mess.Format("Sending %d message %s\r\n",count,buffer);
- WriteMessage( mess );
- }
- }
-}
void CTestDlg::OnClose()
{
@@ -349,32 +319,40 @@ void CTestDlg::OnClose() TRACE ( "Quitting\n");
if (bus) delete bus;
- CDialog::OnClose();
+ ETSLayoutDialog::OnClose();
}
-void CTestDlg::OnOK()
+
+void CTestDlg::OnSend()
{
- // TODO: Add extra validation here
- TRACE ( "Quitting\n");
- if (bus) delete bus;
- CDialog::OnOK();
+ CString buffer;
+ m_msg.SetEditSel( 0, -1 );
+ m_msg.GetWindowText( buffer );
+ if ( buffer.IsEmpty() ) return;
+ int count = bus->SendMsg( buffer );
+ if ( m_msg.FindStringExact(-1, buffer) == CB_ERR )
+ {
+ m_msg.AddString( buffer );
+ }
+ CString mess;
+ mess.Format("Sending %d message %s\r\n",count,buffer);
+ WriteMessage( mess );
+ m_msg.Clear();
}
-void CTestDlg::OnVscrollBind()
+void CTestDlg::OnBind()
{
- char buffer[200];
- int line = m_bind.GetFirstVisibleLine( ) -1 ;
- if ( line >= 0 )
- {
- int len = m_bind.GetLine( line , buffer, sizeof(buffer)-1);
- if ( len )
+ CString buffer;
+ m_expr.SetEditSel( 0, -1 );
+ m_expr.GetWindowText( buffer );
+ if ( buffer.IsEmpty() ) return;
+ int count = bus->BindMsg( buffer , BUS_CALLBACK_OF(CTestDlg, IvyCallback ));
+ if ( m_expr.FindStringExact(-1, buffer) == CB_ERR )
{
- buffer[len] = '\0';
- TRACE("IDC BIND Scroll %d len= %d %s\n",line,len, buffer);
- int count = bus->BindMsg( buffer , BUS_CALLBACK_OF(CTestDlg, IvyCallback ));
- CString mess;
- mess.Format("Binding to '%s'\r\n",buffer);
- WriteMessage( mess );
+ m_expr.AddString( buffer );
}
- }
+ CString mess;
+ mess.Format("Binding to %s\r\n",buffer);
+ WriteMessage( mess );
+ m_expr.Clear();
}
|