2006-04-16

Mu Torere, the Playing Board II

Step 4.
Once the Board class has been set-up, all that needs to be done is to pass the right values to the right functions in the View class. For the moment, create a Game class and two pass-through function for Draw(CDC* pDC) and getSize(void).
Note; if interested here are the in-line functions to specifically catch allocation errors wrt. Board class.
CBoard* getBoard(void)
Get pointer to CBoard instance.

ASSERT that pointer is not-NULL.

Return pointer.

All the second version of the getBoard() function is defined using const to allow the CGame's getSize() function to use it.

Step 5.
It is preferred to use similar pass-through functionality in the program's Document class. (With a private CGame variable.)

Step 6.
Since the View class's onDraw(CDC *pDC) only has one statement to be added, pDoc->Draw(pDC), we will go onto the OnInitialUpdate() function.
void CMuTorereView::OnInitialUpdate(void)
// from the development's' function wizard
Call CView::OnInitialUpdate().

Get the Board class's CSize from the Document.

Increase the retrieved size in the X direction by twice the window's frame.
Increase the retrieved size in the Y direction by the Window's frame + the height of the menu and the height of the titlebar.

Get the width of the desktop.
If the retrieved size is wider than the desktop, then limit the retrieved size's width.

Get the height of the desktop.
If the retrieved size is taller than the desktop, then limit the retrieved size's height.

AfxGetMainWnd()->SetWindowPos(NULL, 0, 0, tSz.cx, tSz.cy, SWP_NOMOVE |
SWP_NOZORDER);

No comments: