CONFIGURATION MANAGEMENT

Page: 1 2 3 4 5 6 7 8 9


Run AppWizard to generate toolbar application.


Use the resource editor to edit the application’s main menu.
- In resource view, double – click on IDR_MAINFRAME.
- create a new menu called draw with the following names & command ID’s
Menu Caption Command ID
Draw Circle ID_DRAW_CIRCLE
Draw Square ID_DRAW_SQUARE
Draw Pattern ID_DRAW_PATTERN
3. Use ClassWizard to add toolbarView class message handlers.
Object ID Message Member Function
ID_DRAW_CIRCLE COMMAND OnDrawCircle
ID_DRAW_CIRCLE UPDATE_COMMAND_UI OnUpdateDrawCircle
ID_DRAW_PATTERN COMMAND OnDrawPattern
ID_DRAW_PATTERN UPDATE_COMMAND_UI OnUpdateDrawPattern
ID_DRAW_SQUARE COMMAND OnDrawSquare
ID_DRAW_SQUARE UPDATE_COMMAND_UI OnUpdateDrawSquare
4. Add three data members to the toolbarView class.
- edit the file toolbarView.h
private:
CRect m_rect;
BOOL m_bCircle;
BOOL m_bPattern;
5. Edit the toolbarView.cpp file
CtoolbarView :: CtoolbarView() : m_rect (0,0,100,100)
{
m_bCircle = TRUE;
m_bPattern = FALSE;
}
Edit the OnDraw function.
void CtoolbarView :: OnDraw (CDC* pDC)
{
CBrush brush(HS_BDIAGONAL, 0L);
if (m_bPattern)
pDC -> SelectObject (&brush);
else
pDC -> SelectStockObject (WHITE_BRUSH);
if (m_bCircle)
pDC -> Ellipse (m_rect);
else
pDC -> Rectangle (m_rect);
pDC -> SelectStockObject (WHITE_BRUSH);
}
Edit the OnDrawCircle, OnDrawSquare and OnDrawPattern function.
void CtoolbarView :: OnDrawCircle()
{
m_bCircle = TRUE;
m_rect += CPoint (25,25);
InvalidateRect (m_rect);
}
void CtoolbarView :: OnDrawSquare()
{
m_bCircle = FALSE;
m_rect += CPoint (25,25);
InvalidateRect (m_rect);
}
void CtoolbarView :: OnDrawPattern()
{
m_bPattern ^= 1;
}
Edit the OnUpdateDrawCircle, OnUpdateDrawSquare and OnUpdateDrawPattern function
void CtoolbarView :: OnUpdateDrawCircle (CCmdUI* pCmdUI)
{
pCmdUI -> Enable (!m-bCircle);
}
void CtoolbarView :: OnUpdateDrawSquare (CCmdUI* pCmdUI)
{
pCmdUI -> Enable (m_bCircle);
}
void CtoolbarView :: OnUpdateDrawPattern (CCmdUI* pCmdUI)
{
pCmdUI -> SetCheck (m_bPattern);
}
8. Build and Test the application.