Click here to Skip to main content
15,896,529 members
Articles / Programming Languages / C++

Bitmap Menu

Rate me:
Please Sign up or sign in to vote.
4.96/5 (13 votes)
8 Mar 2013CPOL1 min read 44.6K   2.2K   33  
A simple way to have a bitmap menu without any bitmap resource or ownerdraw
// TestMenuView.cpp : implementation of the CTestMenuView class
//

#include "stdafx.h"
#include "TestMenu.h"

#include "TestMenuDoc.h"
#include "TestMenuView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTestMenuView

IMPLEMENT_DYNCREATE(CTestMenuView, CEditView)

BEGIN_MESSAGE_MAP(CTestMenuView, CEditView)
	//{{AFX_MSG_MAP(CTestMenuView)
	ON_WM_CONTEXTMENU()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestMenuView construction/destruction

CTestMenuView::CTestMenuView()
{
	// TODO: add construction code here

}

CTestMenuView::~CTestMenuView()
{
}

BOOL CTestMenuView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	BOOL bPreCreated = CEditView::PreCreateWindow(cs);
	cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL);	// Enable word-wrapping

	return bPreCreated;
}

/////////////////////////////////////////////////////////////////////////////
// CTestMenuView drawing

void CTestMenuView::OnDraw(CDC* pDC)
{
	CTestMenuDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CTestMenuView printing

BOOL CTestMenuView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default CEditView preparation
	return CEditView::OnPreparePrinting(pInfo);
}

void CTestMenuView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView begin printing.
	CEditView::OnBeginPrinting(pDC, pInfo);
}

void CTestMenuView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView end printing
	CEditView::OnEndPrinting(pDC, pInfo);
}

/////////////////////////////////////////////////////////////////////////////
// CTestMenuView diagnostics

#ifdef _DEBUG
void CTestMenuView::AssertValid() const
{
	CEditView::AssertValid();
}

void CTestMenuView::Dump(CDumpContext& dc) const
{
	CEditView::Dump(dc);
}

CTestMenuDoc* CTestMenuView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestMenuDoc)));
	return (CTestMenuDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTestMenuView message handlers

void CTestMenuView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here

	CMenu menu;
	menu.LoadMenu(IDR_TESTMETYPE);
	CMenu* pSubMenu = menu.GetSubMenu(1);
	pSubMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, AfxGetMainWnd());
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions