home *** CD-ROM | disk | FTP | other *** search
- // mymenvw.cpp : implementation of the CMymenuView class
- //
-
- #include "stdafx.h"
- #include "mymenu.h"
-
- #include "mymendoc.h"
- #include "mymenvw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMymenuView
-
- IMPLEMENT_DYNCREATE(CMymenuView, CView)
-
- BEGIN_MESSAGE_MAP(CMymenuView, CView)
- //{{AFX_MSG_MAP(CMymenuView)
- ON_COMMAND(ID_FILE_BOLD, OnFileBold)
- ON_COMMAND(ID_FORMAT_SIZE_SIZEPOINT1, OnFormatSizeSizepoint1)
- ON_COMMAND(ID_FORMAT_SIZE_SIZEPOINT2, OnFormatSizeSizepoint2)
- ON_COMMAND(ID_FORMAT_ITALIC, OnFormatItalic)
- ON_UPDATE_COMMAND_UI(ID_FORMAT_ITALIC, OnUpdateFormatItalic)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMymenuView construction/destruction
-
- CMymenuView::CMymenuView()
- {
- // TODO: add construction code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Initialize the data member to 1.
- m_Italic = 1;
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- CMymenuView::~CMymenuView()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMymenuView drawing
-
- void CMymenuView::OnDraw(CDC* pDC)
- {
- CMymenuDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMymenuView diagnostics
-
- #ifdef _DEBUG
- void CMymenuView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CMymenuView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CMymenuDoc* CMymenuView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMymenuDoc)));
- return (CMymenuDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMymenuView message handlers
-
- void CMymenuView::OnFileBold()
- {
- // TODO: Add your command handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Extract the pointer of the parent window.
- CWnd* pParent = GetParent();
-
- // Extract the pointer of the menu
- CMenu* pMenu = pParent->GetMenu();
-
-
- // Extract the pointer of the Format menu
- CMenu* pMenuFormatItem = pMenu->GetSubMenu(1);
-
-
- // Enable the Size menu
- pMenuFormatItem->EnableMenuItem (0,
- MF_BYPOSITION | MF_ENABLED );
-
- // Display a message box
- CString sMessage;
- sMessage = "I'm inside OnFileBold() ";
- MessageBox ( sMessage );
-
- // Invert the value of m_Italic
- if ( m_Italic == 0 )
- m_Italic = 1;
- else
- m_Italic = 0;
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CMymenuView::OnFormatSizeSizepoint1()
- {
- // TODO: Add your command handler code here
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Extract the pointer of the parent window.
- CWnd* pParent = GetParent();
-
- // Extract the pointer of the menu
- CMenu* pMenu = pParent->GetMenu();
-
- // Remove the check mark from the Size point 2 item
- pMenu->CheckMenuItem( ID_FORMAT_SIZE_SIZEPOINT2,
- MF_UNCHECKED );
-
-
- // Place a check mark to the left of
- // the Size point 1 item
- pMenu->CheckMenuItem( ID_FORMAT_SIZE_SIZEPOINT1,
- MF_CHECKED );
-
-
- // Display a message box
- CString sMessage;
- sMessage = "I'm inside Format->Size->Point 1";
- MessageBox ( sMessage );
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
- }
-
- void CMymenuView::OnFormatSizeSizepoint2()
- {
- // TODO: Add your command handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
-
- // Extract the pointer of the parent window.
- CWnd* pParent = GetParent();
-
- // Extract the pointer of the menu
- CMenu* pMenu = pParent->GetMenu();
-
- // Remove the check mark from the Size point 1 item
- pMenu->CheckMenuItem( ID_FORMAT_SIZE_SIZEPOINT1,
- MF_UNCHECKED );
-
-
- // Place a check mark to the left of the Size point 2 item
- pMenu->CheckMenuItem( ID_FORMAT_SIZE_SIZEPOINT2,
- MF_CHECKED );
-
- // Display a message box
- CString sMessage;
- sMessage = "I'm inside Format->Size->Point 2";
- MessageBox ( sMessage );
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CMymenuView::OnFormatItalic()
- {
- // TODO: Add your command handler code here
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- MessageBox ("Format->Italic was selected");
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CMymenuView::OnUpdateFormatItalic(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- if ( m_Italic == 0 )
- pCmdUI->Enable(FALSE);
- else
- pCmdUI->Enable(TRUE);
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-