
This constructor lets you get a string resource from any Windows
application. Y u specify the application by passing an HINST NCEo A
as the first parameter of the string constructor In this case, you can get.
the current application’ instance through the document manager Thes .
GetDocManager function returns a pointer to the document’s
document manager In turn, the GetApplication function returns a.
pointer to the application that contains the document manager This is.
converted implicitly into an HINST NCE by a conversion operator inA
the TModule class. The second parameter of the string constructor is
the resource identifier of a string defined in STEP11DV.RC. This
string contains version information that can be used to identify the
application that created the document.
The Revert function takes a single parameter a BOOL indicating,
whether the document’ views need to refresh their display from thes
document’ data. Revert calls the TFileDocument version of the Reverts
function, which in turn calls the TDocument version of Revert. The
base class function calls the NotifyViews function with the vnRevert
event. The second parameter of the NotifyViews function is set to the
parameter passed to the TDrawDocument::Revert function.
TFileDocument::Revert sets IsDirty to FALSE and returns. If
TFileDocument::Revert returns FALSE, the TDrawDocument should also
return FALSE.
If TFileDocument::Revert returns TRUE, the TDrawDocument function
should check the parameter passed to Revert. If it is FALSE (that is, if
the view needs to be refreshed), Revert calls the Open function to open
the document file, reload the data, and display it.
Here’ how the code for your Commit function might look:s
BOOL TDrawDocument::Revert(BOOL clear)
{
if (!TFileDocument::Revert(clear))
return FALSE;
if (!clear)
Open(0);
return TRUE;
}
There are two main ways to access data in TDrawDocument: adding a
Accessing the
line (such as a new line when the user draws in a view) and getting a
document’ datas
reference to a line in the document (such as getting a reference to each
line when repainting the window). Y u can add two functions,o
AddLine and GetLine, to take care of each of these actions.
82
OWL P ogrammer’ Guider s