To Log a Dialog Waypoint

Dialogs, and the API calls to create waypoints for them, come in two types: modal and modeless. The About dialog in the sample application is a modal dialog. The waypoint for it, and the way it is displayed in the timeline, includes the entire time duration that the dialog was opened. The waypoint is not sent until the dialog is closed. For a modeless dialog, separate waypoints mark when it is opened and closed.

To create the modal dialog waypoint for the About dialog, the sample application adds a dialog waypoint to the CAboutDlg class in ChronicleMFCClient.cpp.

class CAboutDlg : public CDialog
{
...
	 // Modal dialog waypoint.
 	Chronicle::Waypoint *m_waypoint;
...
};

When a user opens the dialog, data is collected and added to the waypoint.

BOOL CAboutDlg::OnInitDialog()
{
	 CDialog::OnInitDialog();

 	// Create modal dialog waypoint.
 	CString strTitle;
 	GetWindowText(strTitle);
 	CRect rc;
 	GetWindowRect(&rc);
 	Chronicle::Rectangle rect(rc.left, rc.top, rc.Width(), rc.Height());
 	m_waypoint = Chronicle::Facade::Waypoints::modalDialogOpened((LPCWSTR)strTitle, rect);

 	return TRUE;
}

When aboutDLg.DoModal() exits, the application tests for a dialog waypoint. If the waypoint exists, it adds the data from modalDialogClosed() and calls waypointReached() to send the waypoint data.

// App command to run the dialog
void CChronicleMFCClientApp::OnAppAbout()
{
	 CAboutDlg aboutDlg;
 	aboutDlg.DoModal();

 	// Report modal dialog waypoint.
 	if (aboutDlg.m_waypoint)
 	{
	  	Chronicle::Facade::Waypoints::modalDialogClosed(aboutDlg.m_waypoint);
	  	Chronicle::Facade::waypointReached(aboutDlg.m_waypoint);
	 }
}