A Journey 2 Eternity

How to post self pop-up menu for CHtmlView in MFC

Posted on: August 21, 2008

Just override the CHtmlView::OnShowContextMenu funcion and return S_OK.

HRESULT CWebBrowserView::OnShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved)
{
	CMenu menu;
	int pMenuID = 0;

	VERIFY(menu.LoadMenu(IDR_WEBBROWSER));
	CMenu* pPopup = menu.GetSubMenu(pMenuID);
	ASSERT(pPopup != NULL);

	pPopup->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, ppt->x, ppt->y, this);

	return S_OK;

	// Don’t call the base version
	//return CHtmlView::OnShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved);
}
Advertisements
Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Categories

August 2008
M T W T F S S
« Apr   Sep »
 123
45678910
11121314151617
18192021222324
25262728293031

Blog Stats

  • 27,491 hits
%d bloggers like this: