Back to index

lightning-sunbird  0.9+nobinonly
CBrowserCtlSite.cpp
Go to the documentation of this file.
00001 // CBrowserCtlSite.cpp : Implementation of CBrowserCtlSite
00002 #include "stdafx.h"
00003 #include "Cbrowse.h"
00004 #include "CBrowserCtlSite.h"
00005 
00006 #include <tchar.h>
00007 #include <string.h>
00008 
00010 // CBrowserCtlSite
00011 
00012 CBrowserCtlSite::CBrowserCtlSite()
00013 {
00014        m_bUseCustomPopupMenu = TRUE;
00015        m_bUseCustomDropTarget = FALSE;
00016 }
00017 
00018 static void _InsertMenuItem(HMENU hmenu, int nPos, int nID, const TCHAR *szItemText)
00019 {
00020        MENUITEMINFO mii;
00021        memset(&mii, 0, sizeof(mii));
00022        mii.cbSize = sizeof(mii);
00023        mii.fMask = MIIM_TYPE;
00024        mii.fType = MFT_STRING;
00025        mii.fState = MFS_ENABLED;
00026        mii.dwTypeData = (LPTSTR) szItemText;
00027        mii.cch = _tcslen(szItemText);
00028        InsertMenuItem(hmenu, nPos, TRUE, &mii);
00029 }
00030 
00031 static void _InsertMenuSeparator(HMENU hmenu, int nPos)
00032 {
00033        MENUITEMINFO mii;
00034        memset(&mii, 0, sizeof(mii));
00035        mii.cbSize = sizeof(mii);
00036        mii.fMask = MIIM_TYPE;
00037        mii.fType = MFT_SEPARATOR;
00038        mii.fState = MFS_ENABLED;
00039        InsertMenuItem(hmenu, nPos, TRUE, &mii);
00040 }
00041 
00043 // IDocHostUIHandler
00044 
00045 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::ShowContextMenu(/* [in] */ DWORD dwID, /* [in] */ POINT __RPC_FAR *ppt, /* [in] */ IUnknown __RPC_FAR *pcmdtReserved, /* [in] */ IDispatch __RPC_FAR *pdispReserved)
00046 {
00047        if (m_bUseCustomPopupMenu)
00048        {
00049               tstring szMenuText(_T("Unknown context"));
00050               HMENU hmenu = CreatePopupMenu();
00051               _InsertMenuItem(hmenu, 0, 1, _T("CBrowse context popup"));
00052               _InsertMenuSeparator(hmenu, 1);
00053               switch (dwID)
00054               {
00055               case CONTEXT_MENU_DEFAULT:
00056                      szMenuText = _T("Default context");
00057                      break;
00058               case CONTEXT_MENU_IMAGE:
00059                      szMenuText = _T("Image context");
00060                      break;
00061               case CONTEXT_MENU_CONTROL:
00062                      szMenuText = _T("Control context");
00063                      break;
00064               case CONTEXT_MENU_TABLE:
00065                      szMenuText = _T("Table context");
00066                      break;
00067               case CONTEXT_MENU_TEXTSELECT:
00068                      szMenuText = _T("TextSelect context");
00069                      break;
00070               case CONTEXT_MENU_ANCHOR:
00071                      szMenuText = _T("Anchor context");
00072                      break;
00073               case CONTEXT_MENU_UNKNOWN:
00074                      szMenuText = _T("Unknown context");
00075                      break;
00076               }
00077 
00078               _InsertMenuItem(hmenu, 2, 2, szMenuText.c_str());
00079 
00080               POINT pt;
00081               GetCursorPos(&pt);
00082               TrackPopupMenu(hmenu, TPM_RETURNCMD, pt.x, pt.y, 0, AfxGetMainWnd()->GetSafeHwnd(), NULL);
00083               DestroyMenu(hmenu);
00084               return S_OK;
00085        }
00086        return S_FALSE;
00087 }
00088 
00089 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::GetHostInfo(/* [out][in] */ DOCHOSTUIINFO __RPC_FAR *pInfo)
00090 {
00091        return E_NOTIMPL;
00092 }
00093 
00094 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::ShowUI(/* [in] */ DWORD dwID, /* [in] */ IOleInPlaceActiveObject __RPC_FAR *pActiveObject, /* [in] */ IOleCommandTarget __RPC_FAR *pCommandTarget, /* [in] */ IOleInPlaceFrame __RPC_FAR *pFrame, /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pDoc)
00095 {
00096        return E_NOTIMPL;
00097 }
00098 
00099 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::HideUI(void)
00100 {
00101        return E_NOTIMPL;
00102 }
00103 
00104 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::UpdateUI(void)
00105 {
00106        return E_NOTIMPL;
00107 }
00108 
00109 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::EnableModeless(/* [in] */ BOOL fEnable)
00110 {
00111        return E_NOTIMPL;
00112 }
00113 
00114 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::OnDocWindowActivate(/* [in] */ BOOL fActivate)
00115 {
00116        return E_NOTIMPL;
00117 }
00118 
00119 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::OnFrameWindowActivate(/* [in] */ BOOL fActivate)
00120 {
00121        return E_NOTIMPL;
00122 }
00123 
00124 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::ResizeBorder(/* [in] */ LPCRECT prcBorder, /* [in] */ IOleInPlaceUIWindow __RPC_FAR *pUIWindow, /* [in] */ BOOL fRameWindow)
00125 {
00126        return E_NOTIMPL;
00127 }
00128 
00129 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::TranslateAccelerator(/* [in] */ LPMSG lpMsg, /* [in] */ const GUID __RPC_FAR *pguidCmdGroup, /* [in] */ DWORD nCmdID)
00130 {
00131        return E_NOTIMPL;
00132 }
00133 
00134 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::GetOptionKeyPath(/* [out] */ LPOLESTR __RPC_FAR *pchKey, /* [in] */ DWORD dw)
00135 {
00136        return E_NOTIMPL;
00137 }
00138 
00139 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::GetDropTarget(/* [in] */ IDropTarget __RPC_FAR *pDropTarget, /* [out] */ IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget)
00140 {
00141        return E_NOTIMPL;
00142 }
00143 
00144 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::GetExternal(/* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppDispatch)
00145 {
00146        return E_NOTIMPL;
00147 }
00148 
00149 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::TranslateUrl(/* [in] */ DWORD dwTranslate, /* [in] */ OLECHAR __RPC_FAR *pchURLIn, /* [out] */ OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut)
00150 {
00151        return E_NOTIMPL;
00152 }
00153 
00154 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::FilterDataObject(/* [in] */ IDataObject __RPC_FAR *pDO, /* [out] */ IDataObject __RPC_FAR *__RPC_FAR *ppDORet)
00155 {
00156        return E_NOTIMPL;
00157 }
00158 
00159 
00161 // IDocHostShowUI
00162 
00163 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::ShowMessage(/* [in] */ HWND hwnd, /* [in] */ LPOLESTR lpstrText, /* [in] */ LPOLESTR lpstrCaption, /* [in] */ DWORD dwType, /* [in] */ LPOLESTR lpstrHelpFile, /* [in] */ DWORD dwHelpContext,/* [out] */ LRESULT __RPC_FAR *plResult)
00164 {
00165        return S_FALSE;
00166 }
00167 
00168 HRESULT STDMETHODCALLTYPE CBrowserCtlSite::ShowHelp(/* [in] */ HWND hwnd, /* [in] */ LPOLESTR pszHelpFile, /* [in] */ UINT uCommand, /* [in] */ DWORD dwData, /* [in] */ POINT ptMouse, /* [out] */ IDispatch __RPC_FAR *pDispatchObjectHit)
00169 {
00170        return S_FALSE;
00171 }
00172