21 ON_BN_CLICKED( IDOK, OnBnClickedOk )
25 ON_LBN_SETFOCUS( IDC_CANMSG_LST_MESSAGES, OnLbnSetfocusList )
26 ON_LBN_KILLFOCUS( IDC_CANMSG_LST_MESSAGES, OnLbnKillfocusMsgList )
27 ON_EN_SETFOCUS( IDC_CANMSG_EDIT_TEXT, OnEnSetfocusMessageEdit )
28 ON_EN_KILLFOCUS( IDC_CANMSG_EDIT_TEXT, OnEnKillfocusMessageEdit )
29 ON_EN_SETFOCUS( IDC_CANMSG_EDIT_ID, OnEnSetfocusMessageEdit )
30 ON_EN_KILLFOCUS( IDC_CANMSG_EDIT_ID, OnEnKillfocusMessageEdit )
39 CCannedTxtMsgDlg::CCannedTxtMsgDlg
46 , mMessageId( _T("") )
47 , mMessageText( _T("") )
66 CDataExchange * aDataExchange
69 CDialog::DoDataExchange( aDataExchange );
84 CDialog::OnInitDialog();
86 SetWindowPos( NULL, 700, 625, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
100 int selectedIndex = mCannedMessageList.GetCurSel();
101 int topIndex = mCannedMessageList.GetTopIndex();
104 mCannedMessageList.ResetContent();
107 for( iter = mCom.mCannedMessages.
begin();
108 iter != mCom.mCannedMessages.
end();
111 if( iter->second.isValid() )
113 listItem.Format( _T(
"%d - %s"), iter->first, iter->second.getCurrentName() );
114 mCannedMessageList.AddString( listItem );
118 mCannedMessageList.SetCurSel( selectedIndex );
119 mCannedMessageList.SetTopIndex( topIndex );
141 if( mMessageText !=
"" && mMessageId !=
"" )
160 int selectedIndex = messageListBox->GetCurSel();
161 if( selectedIndex >= 0 && selectedIndex < messageListBox->GetCount() )
165 messageListBox->GetText( selectedIndex, str );
166 index = str.Find( _T(
"-"), 0 );
169 TCHAR * itemBuffer = str.GetBuffer();
170 TCHAR * messageId =
new TCHAR[index];
171 memcpy( messageId, itemBuffer, ( index - 1 ) *
sizeof( TCHAR ) );
172 messageId[index-1] =
'\0';
173 mMessageId.Format( _T(
"%s"), messageId );
174 int messageTextLength = str.GetLength()-index-1;
175 TCHAR * messageText =
new TCHAR[messageTextLength];
176 memcpy( messageText, itemBuffer + index + 2, ( messageTextLength - 1 ) *
sizeof( TCHAR ) );
177 messageText[messageTextLength - 1] =
'\0';
178 mMessageText.Format( _T(
"%s"), messageText );
181 delete[] messageText;
185 messageListBox->SetCurSel( selectedIndex );
196 if( mSelectedIndex >= 0 )
198 mCom.sendDeleteCannedMessageRequest( mCom.mCannedMessages.getKeyAt( mSelectedIndex ) );
211 uint32 messageId = _ttoi( mMessageId.GetBuffer() );
213 mCom.sendCannedMessage( messageId, mMessageText );
247 CDialog::PostNcDestroy();
269 SendMessage( DM_SETDEFID, IDOK );
289 SendMessage( DM_SETDEFID, IDOK );
void updateListBox()
Update the canned message list box from the canned message map owned by FmiApplicationLayer.
afx_msg void OnEnSetfocusMessageEdit()
Handles the set focus event for the Message ID and Message Text edit boxes.
afx_msg void OnLbnSetfocusList()
Handles the set focus event for the Message List box.
#define IDC_CANMSG_BTN_SEND
afx_msg void OnLbnKillfocusMsgList()
Handles the kill focus event for the Message list box.
const_iterator begin()
Iterator positioned at the first element in the map.
#define IDC_CANMSG_LST_MESSAGES
afx_msg void OnBnClickedOk()
Button handler for the OK button.
afx_msg void OnCancel()
Handler for the Cancel action.
Dialog allowing the user to manage the list of canned messages on the client.
#define IDC_CANMSG_EDIT_TEXT
afx_msg void OnEnChangeEditBoxes()
Edit handler for the Message ID and Message Text boxes.
afx_msg void OnBnClickedDelete()
Handles the Delete button clicked event.
const_iterator end()
Iterator positioned after the last element in the map.
void PostNcDestroy()
Called by MFC after the window has been destroyed; performs final termination activities.
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
afx_msg void OnLbnSelchangeMsglist()
Selection Changed handler for the Message List box.
afx_msg LPARAM OnCannedMsgListChanged(WPARAM, LPARAM)
Handler for the FMI_EVENT_CANNED_MSG_LIST_CHANGED event.
Serial communication controller for Garmin and FMI packets.
BOOL OnInitDialog()
Initialize the dialog.
afx_msg void OnEnKillfocusMessageEdit()
Handles the kill focus event for the Message ID and Message Text edit boxes.
Map whose contents are also saved to a file.
#define IDC_CANMSG_EDIT_ID
#define IDC_CANMSG_BTN_DELETE
#define WM_EVENT(_event)
Translation from an application event to the corresponding Windows message.
#define IDD_CANNED_TXT_MSG
afx_msg void OnBnClickedSend()
Button handler for the Send button.
unsigned long int uint32
32-bit unsigned integer
virtual ~CCannedTxtMsgDlg()
[Brief description of the method]
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.