Solved

still have some problem with Implement IE browser

Posted on 2002-06-19
8
446 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 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
Get filename and folder into excel 7 87
CRON statement to run every 3 minutes except on Monday morning 12am to 2am 7 121
dog bark java program 15 130
Window placement 17 99
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

734 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