Remove items form the window menu
Return to Main

Resume :

  • Remove from the window/system menu, two items - Size and Maximize. Using the RemoveMenu command - member of CMenu class.

    Note:
  • Removemenu, deletes a menu item with an associated pop-up menu.
  • pSysMenu - pointer of CMenu Class type.
  • Details ...

    1. TestVC0Dlg.cpp file - the new Text Code is red.

      // TestVC0Dlg.cpp : implementation file
      //

      #include "stdafx.h"
      #include "TestVC0.h"
      #include "TestVC0Dlg.h"

      #ifdef _DEBUG
      #define new DEBUG_NEW
      #undef THIS_FILE
      static char THIS_FILE[] = __FILE__;
      #endif

      /////////////////////////////////////////////////////////////////////////////
      // CAboutDlg dialog used for App About

      class CAboutDlg : public CDialog
      {
      public:
      CAboutDlg();

      // Dialog Data
      //{{AFX_DATA(CAboutDlg)
      enum { IDD = IDD_ABOUTBOX };
      //}}AFX_DATA

      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CAboutDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
      //}}AFX_VIRTUAL

      // Implementation
      protected:
      //{{AFX_MSG(CAboutDlg)
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      };

      CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
      {
      //{{AFX_DATA_INIT(CAboutDlg)
      //}}AFX_DATA_INIT
      }

      void CAboutDlg::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CAboutDlg)
      //}}AFX_DATA_MAP
      }

      BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
      //{{AFX_MSG_MAP(CAboutDlg)
      // No message handlers
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      /////////////////////////////////////////////////////////////////////////////
      // CTestVC0Dlg dialog

      CTestVC0Dlg::CTestVC0Dlg(CWnd* pParent /*=NULL*/)
      : CDialog(CTestVC0Dlg::IDD, pParent)
      {
      //{{AFX_DATA_INIT(CTestVC0Dlg)
      m_book = _T("");
      m_chapter = _T("");
      m_title = _T("");
      m_verse = _T("");
      m_textdata = _T("");
      m_edword = _T("");
      m_staticfound = _T("");
      //}}AFX_DATA_INIT
      // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
      m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
      m_pDB = NULL;
      m_pRS = NULL;
      m_pRSW0 = NULL;
      }

      void CTestVC0Dlg::DoDataExchange(CDataExchange* pDX)
      {
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CTestVC0Dlg)
      DDX_Control(pDX, IDC_COMBO_TITLE, m_combotitle);
      DDX_Control(pDX, IDC_COMBO_CHAPTER, m_combochapter);
      DDX_Control(pDX, IDC_STATICVERSE, m_staticverse);
      DDX_Control(pDX, IDC_STATICTITLE, m_statictitle);
      DDX_Control(pDX, IDC_STATICSEL, m_staticsel);
      DDX_Control(pDX, IDC_STATICCHAPTER, m_staticchapter);
      DDX_Control(pDX, IDC_STATICBOOK, m_staticbook);
      DDX_Control(pDX, IDC_COMBO_VERSE_RECNO, m_comboverserecno);
      DDX_Control(pDX, IDC_COMBO_VERSE, m_comboverse);
      DDX_Control(pDX, IDC_COMBO_TITLE_RECNO, m_combotitlerecno);
      DDX_Control(pDX, IDC_COMBO_CHAPTER_RECNO, m_combochapterrecno);
      DDX_Control(pDX, IDC_COMBO_BOOK_RECNO, m_combobookrecno);
      DDX_Control(pDX, IDC_COMBO_BOOK, m_combobook);
      DDX_Control(pDX, IDC_STATICTYPE, m_statictype);
      DDX_Control(pDX, IDC_STATICFOUND, m_staticfoundcontrol);
      DDX_Control(pDX, IDC_SEARCHLIST, m_searchlist);
      DDX_Control(pDX, IDC_EDWORD, m_edwordcontrol);
      DDX_Control(pDX, IDC_DISPLAY, m_display);
      DDX_Control(pDX, IDC_TAB1, m_tab1);
      DDX_Text(pDX, IDC_BOOK, m_book);
      DDX_Text(pDX, IDC_CHAPTER, m_chapter);
      DDX_Text(pDX, IDC_TITLE, m_title);
      DDX_Text(pDX, IDC_VERSE, m_verse);
      DDX_Text(pDX, IDC_TEXTDATA, m_textdata);
      DDX_Text(pDX, IDC_EDWORD, m_edword);
      DDX_Text(pDX, IDC_STATICFOUND, m_staticfound);
      //}}AFX_DATA_MAP
      }

      BEGIN_MESSAGE_MAP(CTestVC0Dlg, CDialog)
      //{{AFX_MSG_MAP(CTestVC0Dlg)
      ON_WM_SYSCOMMAND()
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_BN_CLICKED(IDC_RECORD_FIRST, OnRecordFirst)
      ON_BN_CLICKED(IDC_RECORD_PREV, OnRecordPrev)
      ON_BN_CLICKED(IDC_RECORD_NEXT, OnRecordNext)
      ON_BN_CLICKED(IDC_RECORD_LAST, OnRecordLast)
      ON_BN_CLICKED(IDC_ABOUT, OnAbout)
      ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
      ON_EN_CHANGE(IDC_EDWORD, OnChangeEdword)
      ON_BN_CLICKED(IDC_DISPLAY, OnDisplay)
      ON_NOTIFY(NM_CLICK, IDC_SEARCHLIST, OnClickSearchlist)
      ON_CBN_SELCHANGE(IDC_COMBO_BOOK, OnSelchangeComboBook)
      ON_CBN_SELCHANGE(IDC_COMBO_TITLE, OnSelchangeComboTitle)
      ON_CBN_SELCHANGE(IDC_COMBO_CHAPTER, OnSelchangeComboChapter)
      ON_CBN_SELCHANGE(IDC_COMBO_VERSE, OnSelchangeComboVerse)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()

      /////////////////////////////////////////////////////////////////////////////
      // CTestVC0Dlg message handlers

      BOOL CTestVC0Dlg::OnInitDialog()
      {
      CDialog::OnInitDialog();

      // Add "About..." menu item to system menu.

      // IDM_ABOUTBOX must be in the system command range.
      ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
      ASSERT(IDM_ABOUTBOX < 0xF000);

      CMenu* pSysMenu = GetSystemMenu(FALSE);
      if (pSysMenu != NULL)
      {
      CString strAboutMenu;
      strAboutMenu.LoadString(IDS_ABOUTBOX);
      if (!strAboutMenu.IsEmpty())
      {
      pSysMenu->AppendMenu(MF_SEPARATOR);
      pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
      //Remove the Maximize and Size items
      pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
      pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);


      }
      }
      // Set the icon for this dialog. The framework does this automatically
      // when the application's main window is not a dialog
      SetIcon(m_hIcon, TRUE); // Set big icon
      SetIcon(m_hIcon, FALSE); // Set small icon

      // *** Initialize / declaration ***
      m_pDB = new CDaoDatabase;
      m_pRS = new CDaoRecordset(m_pDB);

      TCHAR curdir[MAX_PATH]; //MAX_PATH - Maximum length of directory
      CString Databasename;

      // Get Current Directory
      GetCurrentDirectory( MAX_PATH, curdir );

      //DataBase name, KJV.mdb at Current Directory
      Databasename = (CString)curdir + _T("\\KJV.mdb");
      m_pDB->Open(Databasename);

      m_pRS->Open(dbOpenDynaset, "SELECT * from BibleTable", 0);

      //Move to first available record
      m_pRS->Move(2);
      //Display the content of record
      CalculValue();
      //Stiuation of controls
      SetButtons(TRUE);

      //Initialize the Tab Comtrol
      TC_ITEM TabCtrlItem;
      TabCtrlItem.mask = TCIF_TEXT;
      TabCtrlItem.pszText = " By word ";
      m_tab1.InsertItem( 0, &TabCtrlItem );
      TabCtrlItem.pszText = " By address ";
      m_tab1.InsertItem( 1, &TabCtrlItem );

      //Make these controls visible or invisible, for Tab Control
      m_staticsel.ShowWindow(SW_HIDE);
      m_combobook.ShowWindow(SW_HIDE);
      m_combotitle.ShowWindow(SW_HIDE);
      m_combochapter.ShowWindow(SW_HIDE);
      m_comboverse.ShowWindow(SW_HIDE);
      m_staticbook.ShowWindow(SW_HIDE);
      m_statictitle.ShowWindow(SW_HIDE);
      m_staticchapter.ShowWindow(SW_HIDE);
      m_staticverse.ShowWindow(SW_HIDE);

      m_searchlist.ShowWindow(SW_SHOW);
      m_edwordcontrol.ShowWindow(SW_SHOW);
      m_display.ShowWindow(SW_SHOW);
      m_statictype.ShowWindow(SW_SHOW);
      m_staticfoundcontrol.ShowWindow(SW_SHOW);

      //Show the header row of List Control
      int strWidth1 = m_searchlist.GetStringWidth(_T("00000"));
      m_searchlist.InsertColumn(1, _T("Record"), LVCFMT_LEFT,2*strWidth1, 1);
      m_searchlist.InsertColumn(2, _T("Bk"), LVCFMT_LEFT, strWidth1, 1);
      m_searchlist.InsertColumn(3, _T("Title"), LVCFMT_LEFT, 4*strWidth1, 1);
      m_searchlist.InsertColumn(4, _T("Ch"), LVCFMT_LEFT, strWidth1, 1);
      m_searchlist.InsertColumn(5, _T("Verse"), LVCFMT_LEFT, 3*strWidth1/2, 1);

      // TODO: Add extra initialization here

      return TRUE; // return TRUE unless you set the focus to a control
      }
      ...................................................................................................................................................
      ...................................................................................................................................................

      ...
    Return to Main