home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch20 / picmenu / mainfrm.cpp next >
Encoding:
C/C++ Source or Header  |  1994-01-26  |  2.5 KB  |  105 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "picmenu.h"
  6.  
  7. #include "mainfrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char BASED_CODE THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMainFrame
  16.  
  17. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  18.  
  19. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  20.     //{{AFX_MSG_MAP(CMainFrame)
  21.     ON_WM_CREATE()
  22.     //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CMainFrame construction/destruction
  27.  
  28. CMainFrame::CMainFrame()
  29. {
  30.     // TODO: add member initialization code here
  31. }
  32.  
  33. CMainFrame::~CMainFrame()
  34. {
  35. }
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CMainFrame diagnostics
  39.  
  40. #ifdef _DEBUG
  41. void CMainFrame::AssertValid() const
  42. {
  43.     CFrameWnd::AssertValid();
  44. }
  45.  
  46. void CMainFrame::Dump(CDumpContext& dc) const
  47. {
  48.     CFrameWnd::Dump(dc);
  49. }
  50.  
  51. #endif //_DEBUG
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CMainFrame message handlers
  55.  
  56. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  57. {
  58.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  59.         return -1;
  60.  
  61.      //////////////////////
  62.      // MY CODE STARTS HERE
  63.      //////////////////////
  64.  
  65.     // Extract the pointer of the menu
  66.     CMenu* pMenu = GetMenu();
  67.  
  68.      // Extract the pointer of the Picture Menu menu
  69.      CMenu* pPictureMenu = pMenu->GetSubMenu(1);
  70.  
  71.      // Delete the current items in the Picture Menu menu
  72.      pPictureMenu->DeleteMenu(4, MF_BYPOSITION);
  73.      pPictureMenu->DeleteMenu(3, MF_BYPOSITION);
  74.      //pPictureMenu->DeleteMenu(2, MF_BYPOSITION);
  75.      //pPictureMenu->DeleteMenu(1, MF_BYPOSITION);
  76.      //pPictureMenu->DeleteMenu(0, MF_BYPOSITION);
  77.  
  78.  
  79.        // Create the object of the bitmap.
  80.        CBitmap* pBit;
  81.  
  82.  
  83.        // Load the bitmap
  84.        pBit->LoadBitmap(IDB_BITMAP1);
  85.  
  86.  
  87.      // Append a separator item to the Picture Menu menu
  88.        pPictureMenu->AppendMenu ( MF_SEPARATOR,
  89.                                     ID_PICTUREMENU_ITEM4 );
  90.  
  91.      // Append a bitmap item to the Picture Menu menu
  92.        pPictureMenu->AppendMenu ( MF_ENABLED,
  93.                                     ID_PICTUREMENU_ITEM1,
  94.                                     pBit);
  95.  
  96.      ////////////////////
  97.      // MY CODE ENDS HERE
  98.      ////////////////////
  99.  
  100.     
  101.     // TODO: Add your specialized creation code here
  102.     
  103.     return 0;
  104. }
  105.