?
Solved

still have some problem with Implement IE browser

Posted on 2002-06-19
8
Medium Priority
?
462 Views
Last Modified: 2013-11-20
Hi all,
    I used to post to ask about Implement IE browser
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=mfc&qid=20310762

. I got some useful solution to use IDocHostUIHandler::GetHostInfo .And I found useful help
from microsoft http://msdn.microsoft.com/Downloads/samples/Internet/browser/driller/sample.asp.
So I can prevent scroll bars or change their appearance and the others. But I still have some problem to disable javascript. I try to changed at IDocHostUIHandler::GetHostInfo   like this

HRESULT FAR EXPORT  CCustomControlSite::XDocHostUIHandler::GetHostInfo( DOCHOSTUIINFO* pInfo )
{


 WCHAR* szCSS = L"BODY {background-color:#ffcccc}";
   WCHAR* szNS = L"IE;MyTags;MyTags2='www.microsoft.com'";
   OLECHAR* pCSSBuffer = (OLECHAR*)CoTaskMemAlloc((wcslen(szCSS) + 1) * sizeof(OLECHAR));
   OLECHAR* pNSBuffer = (OLECHAR*)CoTaskMemAlloc((wcslen(szNS) + 1) * sizeof(OLECHAR));
   wcscpy(pCSSBuffer, szCSS);
   wcscpy(pNSBuffer, szNS);

   pInfo->cbSize = sizeof(DOCHOSTUIINFO);
   pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE;
   pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
   pInfo->pchHostCss = pCSSBuffer;
   pInfo->pchHostNS = pNSBuffer;
    return S_OK;
}
But it doesn't disable javascript . Does anyone have an idea  to help me.?
0
Comment
Question by:eakkung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 12

Expert Comment

by:migel
ID: 7094973
Hi!
DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE flag disables JavaScript only during page loading.
Do you want diasable all scripts execution in the page?
0
 

Author Comment

by:eakkung
ID: 7094984
yes I want to diasable all scripts execution in the page.
0
 
LVL 12

Expert Comment

by:migel
ID: 7095023
Hi!
You have to implement Invoke member in the your host

STDMETHODIMP CCustomControlSite::Invoke(DISPID dispidMember, REFIID riid,
                               LCID lcid, WORD wFlags,
                               DISPPARAMS* pDispParams,
                               VARIANT* pvarResult,
                               EXCEPINFO* pExcepInfo,
                               UINT* puArgErr)
{
    switch (dispidMember)
    {
    case DISPID_AMBIENT_DLCONTROL:
        pvarResult->vt = VT_I4;
        pvarResult->lVal = DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_NO_SCRIPTS; //<< here!
        break;

    default:
        return DISP_E_MEMBERNOTFOUND;
    }

    return S_OK;
}
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:eakkung
ID: 7095115
I put your code to my program but it doesn't work.
(javascript still work)

 This is my code  that I put into idispimp.cpp
STDMETHODIMP CImpIDispatch::Invoke(
            /* [in] */ DISPID dispIdMember,
            /* [in] */ REFIID /*riid*/,
            /* [in] */ LCID /*lcid*/,
            /* [in] */ WORD wFlags,
            /* [out][in] */ DISPPARAMS* pDispParams,
            /* [out] */ VARIANT* pVarResult,
            /* [out] */ EXCEPINFO* /*pExcepInfo*/,
            /* [out] */ UINT* puArgErr)
{

     // For this sample we only support a Property Get on DISPID_Extend
     // returning a BSTR with "Wibble" as the value
     if ( dispIdMember == DISPID_Extend )
     {
          if ( wFlags & DISPATCH_PROPERTYGET )
          {
               if ( pVarResult != NULL )
               {
                    WCHAR buff[10]=L"Wibble";
                    BSTR bstrRet = SysAllocString( buff );
                    VariantInit(pVarResult);
                    V_VT(pVarResult)=VT_BSTR;
                    V_BSTR(pVarResult) = bstrRet;
               }
          }
     }
     if ( dispIdMember == DISPID_AMBIENT_DLCONTROL )
     {
       pVarResult->vt = VT_I4;
       pVarResult->lVal = DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_NO_SCRIPTS; //<< here!
   
     }

     return S_OK;
}

it's file from microsoft sample (driller). I do something wrong?   and do you have some sample ?
0
 
LVL 12

Accepted Solution

by:
migel earned 920 total points
ID: 7095363
Hi!
Here is code to achieve this in the Drill APP

//custsite.h
class CCustomControlSite:public COleControlSite
{
public:
     CCustomControlSite(COleControlContainer *pCnt):COleControlSite(pCnt){}

protected:

     DECLARE_INTERFACE_MAP();
     BEGIN_INTERFACE_PART(AmbientProps1, IDispatch)
          INIT_INTERFACE_PART(CCustomControlSite, AmbientProps1)
          STDMETHOD(GetTypeInfoCount)(unsigned int*);
          STDMETHOD(GetTypeInfo)(unsigned int, LCID, ITypeInfo**);
          STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, unsigned int, LCID, DISPID*);
          STDMETHOD(Invoke)(DISPID, REFIID, LCID, unsigned short, DISPPARAMS*,
                                VARIANT*, EXCEPINFO*, unsigned int*);
     END_INTERFACE_PART(AmbientProps1)
// rest of file rmeain unchanged:


/////////////////////////////////////////////////////
//custsite.cpp
// add thise lines
#include <MSHTMDID.H>
BEGIN_INTERFACE_MAP(CCustomControlSite, COleControlSite)
     INTERFACE_PART(CCustomControlSite, IID_IDispatch, AmbientProps1)
// rest of interface map
END_INTERFACE_MAP()


/// file content unchanged
// add this:
STDMETHODIMP CCustomControlSite::XAmbientProps1::Invoke(
     DISPID dispid, REFIID, LCID, unsigned short wFlags,
     DISPPARAMS* pDispParams, VARIANT* pvarResult,
     EXCEPINFO*, unsigned int*)
{
METHOD_PROLOGUE_EX_(CCustomControlSite, AmbientProps1)
   switch (dispid)
   {
   case DISPID_AMBIENT_DLCONTROL:
       pvarResult->vt = VT_I4;
       pvarResult->lVal = DLCTL_DLIMAGES | DLCTL_VIDEOS | DLCTL_NO_SCRIPTS; //<< here!
       break;

   default:
          return pThis->m_pCtrlCont->m_pWnd->OnAmbientProperty(pThis, dispid, pvarResult) ?
               S_OK : DISP_E_MEMBERNOTFOUND;
   }
     return S_OK;
}

/////////////////////////////////////////////////////////////////////////////
// COleControlSite::XAmbientProps1

STDMETHODIMP_(ULONG) CCustomControlSite::XAmbientProps1::AddRef()
{
     METHOD_PROLOGUE_EX_(CCustomControlSite, AmbientProps1)
     return (ULONG)pThis->InternalAddRef();
}

STDMETHODIMP_(ULONG) CCustomControlSite::XAmbientProps1::Release()
{
     METHOD_PROLOGUE_EX_(CCustomControlSite, AmbientProps1)
     return (ULONG)pThis->InternalRelease();
}

STDMETHODIMP CCustomControlSite::XAmbientProps1::QueryInterface(
     REFIID iid, LPVOID* ppvObj)
{
     METHOD_PROLOGUE_EX_(CCustomControlSite, AmbientProps1)
     return (HRESULT)pThis->InternalQueryInterface(&iid, ppvObj);
}

STDMETHODIMP CCustomControlSite::XAmbientProps1::GetTypeInfoCount(
     unsigned int*)
{
     return E_NOTIMPL;
}

STDMETHODIMP CCustomControlSite::XAmbientProps1::GetTypeInfo(
     unsigned int, LCID, ITypeInfo**)
{
     return E_NOTIMPL;
}

STDMETHODIMP CCustomControlSite::XAmbientProps1::GetIDsOfNames(
     REFIID, LPOLESTR*, unsigned int, LCID, DISPID*)
{
     return E_NOTIMPL;
}

// GOOD LUCK!
0
 

Author Comment

by:eakkung
ID: 7095412
Hi!  
   It 's work !! .I'm really appreciate. Would you mind to suggest  me how I can get more information about it ? I saw some information in msdn about web browser customization. But I don't understand how I can implement it.
 I'm beginning  in  ATL , COM .

Thank for you kind .
0
 
LVL 12

Expert Comment

by:migel
ID: 7095426
Hi!
You have to read MSDN part WEB workshop also MSDN search tool can help but in this case defining accurate search phrase is main problem :-)
GOOD LUCK!
0
 

Author Comment

by:eakkung
ID: 7095479
Hi ,
 Thank you ! I think so. msdn has a lot of information. what 's
key word that you use to search for this case.?  I 'm so surprise that you can find it.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question