Garmin Fleet Management Controller  2.19.0
CCommErrorDlg Class Reference

Modal dialog displaying a communication error. More...

#include <CCommErrorDlg.h>

+ Inheritance diagram for CCommErrorDlg:

Public Member Functions

 CCommErrorDlg (TCHAR *aErrorMessage, BOOL aCommPortDown, CWnd *aParent, FmiApplicationLayer &aCom)
 Constructor. More...
 
virtual ~CCommErrorDlg ()
 Destructor. More...
 

Protected Member Functions

virtual void DoDataExchange (CDataExchange *aDataExchange)
 Perform dialog data exchange and validation. More...
 
afx_msg void OnBnClickedChangeCom ()
 Click handler for the Change Port button. More...
 
afx_msg void OnBnClickedExit ()
 Click handler for the Exit button. More...
 
afx_msg void OnBnClickedRetry ()
 Click handler for the Retry button. More...
 
void OnCancel ()
 Cancel action handler. More...
 
BOOL OnInitDialog ()
 Initialize the dialog. More...
 
void PostNcDestroy ()
 Called by MFC after the window has been destroyed; performs final termination activities. More...
 

Static Protected Member Functions

static BOOL CALLBACK OnCloseHelper (HWND hWndParent, LPARAM lParam)
 Helper for EnumThreadWindows call. More...
 

Protected Attributes

FmiApplicationLayermCom
 The FMI communication controller. More...
 
BOOL mComPortDown
 If TRUE, communication is down and the serial port will need to be reinitialized to continue. More...
 
CString mMessageText
 The message to display to the user. More...
 

Detailed Description

Modal dialog displaying a communication error.

Gives the user the option to exit, retry the operation, or change the com port.

Definition at line 22 of file CCommErrorDlg.h.

Constructor & Destructor Documentation

CCommErrorDlg::CCommErrorDlg ( TCHAR *  aErrorMessage,
BOOL  aIsPortDown,
CWnd *  aParent,
FmiApplicationLayer aCom 
)

Constructor.

Parameters
aErrorMessageThe error message to display
aIsPortDownIf true, indicates that the com port is down, and the OK button is replaced by Exit, Retry, and Change Port buttons.
aParentThe parent window
aComThe FmiApplicationLayer that should be notified when communication resumes

Definition at line 35 of file CCommErrorDlg.cpp.

CCommErrorDlg::~CCommErrorDlg ( )
virtual

Destructor.

Definition at line 52 of file CCommErrorDlg.cpp.

References DoDataExchange().

Member Function Documentation

void CCommErrorDlg::DoDataExchange ( CDataExchange *  aDataExchange)
protectedvirtual

Perform dialog data exchange and validation.

Parameters
aDataExchangeThe DDX context

Definition at line 61 of file CCommErrorDlg.cpp.

References IDC_ERROR_TXT_MESSAGE, and mMessageText.

Referenced by ~CCommErrorDlg().

void CCommErrorDlg::OnBnClickedChangeCom ( )
protected

Click handler for the Change Port button.

Display the Select Port dialog, then (if a port was selected) retry the communication.

Definition at line 158 of file CCommErrorDlg.cpp.

References OnBnClickedRetry().

void CCommErrorDlg::OnBnClickedExit ( )
protected

Click handler for the Exit button.

Exit the application by sending WM_CLOSE to the main window.

Definition at line 97 of file CCommErrorDlg.cpp.

References FALSE, mComPortDown, OnCancel(), and OnCloseHelper().

void CCommErrorDlg::OnBnClickedRetry ( )
protected

Click handler for the Retry button.

Re-enable the communication link and make sure an enable packet is sent if appropriate.

Definition at line 142 of file CCommErrorDlg.cpp.

References FmiApplicationLayer::clearError(), mCom, and FmiApplicationLayer::sendEnable().

Referenced by OnBnClickedChangeCom().

void CCommErrorDlg::OnCancel ( )
protected

Cancel action handler.

Dismiss the dialog if the com port is not down (otherwise com state would be violated).

Definition at line 129 of file CCommErrorDlg.cpp.

References mComPortDown.

Referenced by OnBnClickedExit().

BOOL CALLBACK CCommErrorDlg::OnCloseHelper ( HWND  hWndParent,
LPARAM  lParam 
)
staticprotected

Helper for EnumThreadWindows call.

This function is called by EnumThreadWindows for each active top-level window associated with a given thread. It sends a command to each window to close itself. This allows any open modal dialogs to be closed by the comm error dialog. Unfortunately, it does not appear to affect dialogs that were not directly based on the main frame (e.g. file transfer progress dialog).

Definition at line 115 of file CCommErrorDlg.cpp.

References TRUE.

Referenced by OnBnClickedExit().

BOOL CCommErrorDlg::OnInitDialog ( )
protected

Initialize the dialog.

This function is called when the window is created. It sets up the parent, so it can get info from and send a message to FmiApplicationLayer. It also hides the OK button and shows the Exit, Retry, and Change Port buttons if the com port is down (as indicated in the constructor).

Returns
TRUE, since this function does not set focus to a control

Definition at line 78 of file CCommErrorDlg.cpp.

References IDC_ERROR_BTN_CHANGE_PORT, IDC_ERROR_BTN_EXIT, IDC_ERROR_BTN_RETRY, mComPortDown, and TRUE.

void CCommErrorDlg::PostNcDestroy ( )
protected

Called by MFC after the window has been destroyed; performs final termination activities.

This dialog is displayed in response to particular events; to prevent its message loop from interrupting another Windows message that may be in progress, this dialog is created modeless. PostNcDestroy sends an event to notify its creator that the dialog is safe to delete.

Definition at line 176 of file CCommErrorDlg.cpp.

References EVENT_COMM_ERROR_DLG_CLOSED, and Event::post().

Member Data Documentation

FmiApplicationLayer& CCommErrorDlg::mCom
protected

The FMI communication controller.

Definition at line 61 of file CCommErrorDlg.h.

Referenced by OnBnClickedRetry().

BOOL CCommErrorDlg::mComPortDown
protected

If TRUE, communication is down and the serial port will need to be reinitialized to continue.

Definition at line 58 of file CCommErrorDlg.h.

Referenced by OnBnClickedExit(), OnCancel(), and OnInitDialog().

CString CCommErrorDlg::mMessageText
protected

The message to display to the user.

Definition at line 54 of file CCommErrorDlg.h.

Referenced by DoDataExchange().


The documentation for this class was generated from the following files: