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
Solved

still have some problem with Implement IE browser

Posted on 2002-06-19
8
440 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
isEverywhere  challenge 19 82
mapBully challenge 6 152
Not needed 13 119
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

840 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