The sample application defines its document handling methods in ChronicleMFCClientDoc.cpp. This file illustrates how to create waypoints for the file-handling operations.
The sample application creates placeholder thumbnail images whenever the document-handling functions need an image. There are two types of placeholder thumbnails. One is provided as an image URL. The other is generated as needed. To illustrate the dynamic nature of the dynamic thumbnail images, this placeholder image includes a timestamp. In an actual application, you create a function that generates a thumbnail image based on the current state of your application's document.
In OnNewDocument(), which is part of the application template, code is included to get the placeholder thumbnail URL and add it to the waypoint using newDocument(). Then waypointReached() sends the waypoint to the Screencast recorder.
BOOL CChronicleMFCClientDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// Test case: document thumbnail from URL.
LPCWSTR lpszFakeThumbnailURL = L"http://www.autodeskresearch.com/img/thumb_projects_nucleus.jpg";
// Report new document waypoint.
LPCWSTR lpszPath = L"";
Chronicle::Waypoint *waypoint = Chronicle::Facade::Waypoints::newDocument(
(LPCWSTR)GetTitle(), lpszPath, lpszFakeThumbnailURL);
Chronicle::Facade::waypointReached(waypoint);
return TRUE;
}
In OnOpenDocument(), the function GenerateThumbnail() generates a dynamic thumbnail that includes a color gradient and a timestamp. The document's title, path, and image are passed to documentOpened(). Then waypointReached() sends the data to the Screencast recorder.
BOOL CChronicleMFCClientDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// [HACK] MFC doesn't set the pathname until after this method returns.
SetPathName(lpszPathName);
// Generate document thumbnail.
Chronicle::Variant thumbnail;
CBitmap *pBitmap = GenerateThumbnail();
if (pBitmap)
{
thumbnail.setValue(Chronicle::Image((HBITMAP)pBitmap->GetSafeHandle()));
}
// Report document opened waypoint.
Chronicle::Waypoint *waypoint = Chronicle::Facade::Waypoints::documentOpened(
(LPCWSTR)GetTitle(), (LPCWSTR)GetPathName(), thumbnail);
Chronicle::Facade::waypointReached(waypoint);
// Destroy thumbnail.
if (pBitmap)
{
delete pBitmap;
}
return TRUE;
}