A Journey 2 Eternity

Posts Tagged ‘MFC

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);
}
Tags: ,

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

HRESULT CWebBrowserView::OnShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved)
{
	return S_OK;

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

(01) Always write optimize and good code in WM_PAINT, WM_MOUSEMOVE and WM_CTLCOLOR event handler. In these three event handlers is always called and it’s tough to debug if any bug exists.

(02) When you got the device context by GetDC() api, you must make sure to release the device context by ReleaseDC() api after painting.

Tags:

When you want a class, who will dynamically created by CreateObject(), then you must have a default constructor. Otherwise you got “Compiler Error C2512 – no appropriate default constructor available”.

To recreate a Control you must:


1. Store rectangle and previous window in Z order (to keep Tab work normally)
2. Destroy Control by DestroyWindow;
3.Create Control by CreateWindow(); // put here your styles.
4. move window to proper Z order by:
SetWindowPos(&wndPrev, 0,0,0,0, SWP_NOMOVE_SWP_NOSIZE|SWP_NOZCTIVATE);

Tags:

Pages

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Blog Stats

  • 32,540 hits