A SERVICE OF

logo

After that, SaveFile sets up an iterator called i from Line. This iterator goes
through all the points contained in the Line array Each point is then.
inserted into the stream until there are no points left.
Lastly IsNewFile and IsDirty are set to FALSE. Here is how the SaveFile,
function should look:
void TMyWindow::SaveFile()
{
ofstream os(FileData->FileName);
if (!os)
MessageBox("Unable to open file", "File Error",
MB_OK | MB_ICONEXCLAMATION);
else {
os << Line->GetItemsInContainer();
TPointsIterator i(*Line);
while (i)
os << i++;
IsNewFile = IsDirty = FALSE;
}
}
The CmAbout function demonstrates how easy it is to use custom dialog
CmAbout function
boxes in ObjectWindows. This function contains only one line of code. It
uses the TDialog class and the IDD_ABOUT dialog box resource to pop up
an information dialog box.
TDialog can take up to three parameters:
The first parameter is a pointer to the dialog box’ parent window. Just ass
with the TFileOpenDialog and TFileSaveDialog constructors, you can use
the this pointer setting the parent window to the TMyWindow object.,
The second parameter is a reference to a TResId object. This should be the
resource identifier of the dialog box resource.
Usually you don’t actually pass in a TResId reference. Instead you pass a
resource identifier number or string, just as you would for a dialog box
created using regular Windows API calls. Conversion operators in the
TResId class resolve the parameter into the proper type.
The third parameter a TModule *, usually uses its default value.,
Once the dialog box object is constructed, all that needs to be done is to call
the Execute function. Once the user closes the dialog box and execution is
complete, CmAbout returns. The temporary TDialog object goes out of scope
and disappears.
The code for CmAbout should look like this:
Chapter 2, Learning ObjectWindows
59