Posts Tagged ‘MFC’
- In: MFC
- Leave a Comment
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); }
- In: MFC
- Leave a Comment
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); }
BE CAREFUL!!!
Posted April 15, 2008
on:- In: MFC
- Leave a Comment
(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.
DECLARE_DYNCREATE problem
Posted April 10, 2008
on:- In: C/C++ | MFC
- Leave a Comment
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”.
- In: MFC
- Leave a Comment
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);