23 ON_BN_CLICKED( IDOK, OnBnClickedOk )
24 ON_EN_SETFOCUS( IDC_CANRESP_EDIT_TEXT, OnEnSetfocusResponseEdit )
25 ON_EN_KILLFOCUS( IDC_CANRESP_EDIT_TEXT, OnEnKillfocusResponseEdit )
26 ON_EN_SETFOCUS( IDC_CANRESP_EDIT_ID, OnEnSetfocusResponseEdit )
27 ON_EN_KILLFOCUS( IDC_CANRESP_EDIT_ID, OnEnKillfocusResponseEdit )
29 ON_LBN_SETFOCUS( IDC_CANRESP_LST_RESPONSES, OnLbnSetfocusResponselist )
30 ON_LBN_KILLFOCUS( IDC_CANRESP_LST_RESPONSES, OnLbnKillfocusResponselist )
39 CManageCannedResponseDlg::CManageCannedResponseDlg
46 , mSelectedResponseIndex( 0 )
47 , mResponseId( _T("") )
48 , mResponseText( _T("") )
65 CDataExchange * aDataExchange
68 CDialog::DoDataExchange( aDataExchange );
84 CDialog::OnInitDialog();
88 SetWindowPos( NULL, 700, 350, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
103 int selectedIndex = mListBox.GetCurSel();
104 int topIndex = mListBox.GetTopIndex();
107 mListBox.ResetContent();
109 for( ; iter != mCom.mCannedResponses.
end(); iter++ )
111 if( iter->second.isValid() )
113 listItem.Format( _T(
"%d - %s"), iter->first, iter->second.getCurrentName() );
114 mListBox.AddString( listItem );
118 mListBox.SetCurSel( selectedIndex );
119 mListBox.SetTopIndex( topIndex );
130 if( mSelectedResponseIndex >= 0 )
132 mCom.sendDeleteCannedResponseRequest( mCom.mCannedResponses.getKeyAt( mSelectedResponseIndex) );
156 uint32 responseId = _ttoi( mResponseId.GetBuffer() );
158 mCom.sendCannedResponse( responseId, mResponseText );
169 if( mResponseText !=
"" && mResponseId !=
"" )
189 int selectedIndex = responseListBox->GetCurSel();
191 if( selectedIndex >= 0 && selectedIndex < responseListBox->GetCount() )
195 responseListBox->GetText( selectedIndex, itemText );
196 index = itemText.Find( _T(
"-"), 0 );
199 TCHAR * itemBuffer = itemText.GetBuffer();
201 TCHAR * responseId =
new TCHAR[index];
202 memcpy( responseId, itemBuffer, ( index - 1 ) *
sizeof( TCHAR ) );
203 responseId[index-1] =
'\0';
204 mResponseId.Format( _T(
"%s"), responseId );
206 int responseTextLength = itemText.GetLength()-index-1;
207 TCHAR * responseText =
new TCHAR[responseTextLength];
208 memcpy( responseText, &itemBuffer[index + 2], ( responseTextLength - 1 ) *
sizeof( TCHAR ) );
209 responseText[responseTextLength - 1] =
'\0';
210 mResponseText.Format( _T(
"%s"), responseText );
212 itemText.ReleaseBuffer();
214 delete[] responseText;
219 responseListBox->SetCurSel( selectedIndex );
252 CDialog::PostNcDestroy();
275 SendMessage( DM_SETDEFID, IDOK );
295 SendMessage( DM_SETDEFID, IDOK );
afx_msg void OnLbnSelchangeResponselist()
Selection Changed handler for the Response List box.
const_iterator begin()
Iterator positioned at the first element in the map.
afx_msg void OnCancel()
Handler for the Cancel action.
Dialog allowing the user to manage canned responses.
#define IDC_CANRESP_BTN_DELETE
afx_msg void OnLbnKillfocusResponselist()
Handles the kill focus event for the Response List box.
const_iterator end()
Iterator positioned after the last element in the map.
#define IDC_CANRESP_BTN_SEND
void PostNcDestroy()
Called by MFC after the window has been destroyed; performs final termination activities.
afx_msg void OnBnClickedSend()
Button handler for the Send button.
afx_msg void OnEnSetfocusResponseEdit()
Handles the set focus event for the Response ID and Response Text edit boxes.
#define IDD_CANNED_RESPONSE
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
afx_msg void OnEnChangeRspBoxes()
Edit handler for the Response ID and Response Text boxes.
Serial communication controller for Garmin and FMI packets.
void updateListBox()
Update the canned response list box from the canned response map owned by FmiApplicationLayer.
#define IDC_CANRESP_LST_RESPONSES
afx_msg void OnBnClickedDelete()
Button handler for the Delete button.
afx_msg void OnEnKillfocusResponseEdit()
Handles the kill focus event for the Response ID and Response Text edit boxes.
virtual ~CManageCannedResponseDlg()
Destructor.
afx_msg void OnLbnSetfocusResponselist()
Handles the set focus event for the Response List.
Map whose contents are also saved to a file.
BOOL OnInitDialog()
This function is called when the window is created.
#define WM_EVENT(_event)
Translation from an application event to the corresponding Windows message.
afx_msg void OnBnClickedOk()
Button handler for the OK button.
unsigned long int uint32
32-bit unsigned integer
#define IDC_CANRESP_EDIT_TEXT
afx_msg LPARAM OnCannedRespListChanged(WPARAM, LPARAM)
Handler for FMI_EVENT_CANNED_RESP_LIST_CHANGED event.
#define IDC_CANRESP_EDIT_ID
static void post(EventId aEventId, uint32 aEventData=0, void *aEventDataPtr=NULL, BOOL handleNow=FALSE)
Posts a message to all windows that have registered to get events.