Solved

still have some problem with Implement IE browser

Posted on 2002-06-19
8
428 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
  • 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Accepted Solution

by:
migel earned 230 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 76
only14 challenge 19 64
noX challenge 17 76
Path of Workbook 3 45
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now