Game Development Reference
In-Depth Information
Finally, we will add a new menu item using
the resource editor in Visual C++. This new
item has a unique ID.
If we again use Class Wizard we can add
a message map handler to the CMainframe
class to handle the new menu item. The
CMainframe class accesses the document
using GetActiveDocument . This function
returns a pointer to the document which must be cast to the specific
document type for your application. To make sure this is possible,
remember to add the header file for your document to the start of the
'mainfrm.cpp' file. This simple function gets the centre of the current frame
window and re-centres the document's rectangle to this centre. Having
done this, it uses the CDocument function UpdateAllViews to tell the view
to redraw itself.
Figure B.11 Adding a new
menu item.
void CMainFrame::OnEditCentre()
CRect rect;
CPoint cen;
cen.x = rect.Width()/2;
cen.y = rect.Height()/2;
CMFCSingleDocDoc *doc =
CSize size; = doc->rect.Width()/2; = doc->rect.Height()/2;
doc->rect.SetRect(cen.x-, cen.y -,
cen.x +, cen.y +;
Search Nedrilad ::

Custom Search