Solved

still have some problem with Implement IE browser

Posted on 2002-06-19
8
436 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 135
Detect CR LF to each line 12 158
fizzArray2 challenge 1 78
JQuery serialize and unserialize 8 77
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

786 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