HRESULT WebBrowserEventSinker::SetCustomDocUIHandler(LPDISPATCH lpDisp)
{
	if(lpDisp == NULL)
		return E_INVALIDARG;

	IWebBrowser2Ptr pWebBrowser2;
	HRESULT hr = lpDisp->QueryInterface(IID_IWebBrowser2, (void**)&pWebBrowser2);

	if(SUCCEEDED(hr) && pWebBrowser2)
	{
		IDispatchPtr pDoc;
		hr = pWebBrowser2->get_Document(&pDoc);

		if(SUCCEEDED(hr) && pDoc)
		{
			ICustomDocPtr pCustDoc;
			hr = pDoc->QueryInterface(IID_ICustomDoc, (void**)&pCustDoc);
			if(SUCCEEDED(hr) && pCustDoc != NULL)
			{				
				IDocHostUIHandler* pUIHandler;
				CreateObjectInterface<CDocHostUIHandler, IDocHostUIHandler>(NULL, &pUIHandler);

				if (pUIHandler)
					pCustDoc->SetUIHandler(pUIHandler);

				pUIHandler->Release();
			}
		}
	}

	return hr;
}
Esempio n. 2
0
/* Toggle a button and return the new state.  */
static void
toggle_button (LPDISPATCH button, const char *tag, int instid)
{
  int state;
  char tag2[256];
  char *p;
  LPDISPATCH inspector;
  
  inspector = get_inspector_from_instid (instid);
  if (!inspector)
    {
      log_debug ("%s:%s: inspector not found", SRCNAME, __func__);
      return;
    }

  state = get_oom_int (button, "State");
  log_debug ("%s:%s: button `%s' state is %d", SRCNAME, __func__, tag, state);
  state = (state == msoButtonUp)? msoButtonDown : msoButtonUp;
  put_oom_int (button, "State", state);

  /* Toggle the other button.  */
  mem2str (tag2, tag, sizeof tag2 - 2);
  p = strchr (tag2, '#');
  if (p)
    *p = 0;  /* Strip the instance id suffix.  */
  if (*tag2 && tag2[1] && !strcmp (tag2+strlen(tag2)-2, "@t"))
    tag2[strlen(tag2)-2] = 0; /* Remove the "@t".  */
  else
    strcat (tag2, "@t");      /* Append a "@t".  */
  
  log_debug ("%s:%s: setting `%s' state to %d", SRCNAME, __func__, tag2, state);
  set_one_button (inspector, tag2, state);
  inspector->Release ();
}
Esempio n. 3
0
/* Return the button with TAG and assigned to INSPECTOR.  TAG must be
   given without the suffix.  Returns NULL if not found.  */
static LPDISPATCH
get_button (LPDISPATCH inspector, const char *tag)
{
  LPDISPATCH result = NULL;
  inspector_info_t iinfo;
  button_list_t ol;

  lock_all_inspectors ();

  for (iinfo = all_inspectors; iinfo; iinfo = iinfo->next)
    if (iinfo->inspector == inspector)
      {
        for (ol = iinfo->buttons; ol; ol = ol->next)
          if (ol->tag && !strcmp (ol->tag, tag))
            {
              result = ol->button;
              if (result)
                result->AddRef ();
              break;
            }
        break;
      }
  
  unlock_all_inspectors ();
  return result;
}
Esempio n. 4
0
//OLECMDID_PRINT	= 6,
HRESULT CWtlHtmlView::ExecCommand( OLECMDID nCmdID, OLECMDEXECOPT nCmdExecOpt, VARIANTARG* pvarargIn, VARIANTARG* pvarargOut) 
{
	HRESULT hr=S_OK;
	LPDISPATCH lpDispatch = NULL;
	LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
	try {

		m_spWebBrowser2->get_Document(&lpDispatch);
		if(lpDispatch==NULL)
			throw;
		OLECMDF eQuery ; //      'return value type for QueryStatusWB

		if(FAILED( m_spWebBrowser2->QueryStatusWB(OLECMDID_PRINT, &eQuery))) //  'get print command status
			throw;

		if(!( eQuery & OLECMDF_ENABLED) )
			throw;

		lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&lpOleCommandTarget);
		if(lpOleCommandTarget==NULL)
			throw;

		// Print contents of WebBrowser control.
		hr=lpOleCommandTarget->Exec(NULL, nCmdID, nCmdExecOpt, pvarargIn, pvarargOut);
	}
	catch(...)
	{
		hr=E_FAIL;
	}
	if(lpDispatch)
		lpDispatch->Release();
	if(lpOleCommandTarget)
		lpOleCommandTarget->Release();
	return hr;
}
void CIncrementSystemBFDlg::DocumentCompleteExplorerSelectItem(LPDISPATCH pDisp, VARIANT* URL)
{
	CString url = URL->bstrVal;

	if (url.Find(cUrls.Logon) > 0){
		TRACE("UnLoadhook");
		unloadhook();
		isLogon = true;
	}
	if (isLogon){
		if (url.Find(cUrls.Http1) > 0){
			TRACE("Loadhook");
			loadhook();
			isLogon = false;
		}
	}
    IUnknown*  pUnk;  
    LPDISPATCH lpWBDisp;  
    HRESULT    hr;  
 
    pUnk = m_MyIE.GetControlUnknown();  
    ASSERT(pUnk);  
 
    hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);  
    ASSERT(SUCCEEDED(hr));  
 
    if (pDisp == lpWBDisp )  
    {
        //TRACE("Web document is finished downloading/n");//这里就是最佳获取时机的判断
    }
    pUnk->Release();
    lpWBDisp->Release();
}
Esempio n. 6
0
VARIANT CWebDlg::ExecuteScript(CString csCode, CString csLanguage)
{
	COleVariant   varRet;

	IHTMLDocument2* pHTMLDocument2;
	IHTMLWindow2*   pHTMLWindow2;
	LPDISPATCH lpDispatch;
	lpDispatch = m_explore.GetDocument();
   
	BSTR            bstrCode    = _bstr_t((const char *)csCode);
	BSTR            bstrLang    = _bstr_t((const char *)csLanguage);
	HRESULT         hr;
 
	if(lpDispatch)
	{
		hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDocument2);
		if(hr == S_OK)
		{
			hr = pHTMLDocument2->get_parentWindow(&pHTMLWindow2);
			if(hr == S_OK)
			{
				pHTMLWindow2->execScript(bstrCode, bstrLang, &varRet);
				pHTMLWindow2->Release();
			}
			pHTMLDocument2->Release();
		}
		lpDispatch->Release();
	}
	return varRet;
}
void
addCircleThroughCom()
{
    AutoCAD::IAcadApplication *pAcad;
    AutoCAD::IAcadDocument *pDoc;
    AutoCAD::IAcadModelSpace *pMSpace;

    HRESULT hr = NOERROR;
    LPUNKNOWN pUnk = NULL;
    LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE); 
	if(pAcadDisp==NULL)
		return;
	
	hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad);
	pAcadDisp->Release();
	if (FAILED(hr))
		return;

	hr = pAcad->get_ActiveDocument(&pDoc);
	pAcad->Release();
	if (FAILED(hr))
		return;

	hr = pDoc->get_ModelSpace(&pMSpace);
	pDoc->Release();
	if (FAILED(hr))
		return;


    SAFEARRAYBOUND rgsaBound;
    rgsaBound.lLbound = 0L;
    rgsaBound.cElements = 3;
    long i;
    SAFEARRAY* pStartPoint = NULL;
    pStartPoint = SafeArrayCreate(VT_R8, 1, &rgsaBound);

    i = 0;
    double value = 4.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    i = 1;
    value = 2.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    i = 2;
    value = 0.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    VARIANT pt1;
    pt1.vt = VT_ARRAY | VT_R8;
    pt1.parray = pStartPoint;

    AutoCAD::IAcadCircle *pCircle;
    pMSpace->AddCircle(pt1, 2.0, &pCircle);
	VariantClear(&pt1);
    pMSpace->Release();
}
Esempio n. 8
0
bool getAcadMenuGroup(IAcadMenuGroup  **pVal)
{

    IAcadApplication *acadApp = NULL;
    LPDISPATCH  pDisp = NULL;

    if (!getApplication(&pDisp))
        return false;

    HRESULT hr = S_OK;
    hr = pDisp->QueryInterface(IID_IAcadApplication, (LPVOID*)&acadApp);
    if (FAILED(hr))
        return false;


    LPDISPATCH  pTempDisp = NULL;
    IAcadMenuGroups *mnuGrps = NULL;
    long cnt = 0;

    //get the menu groups
    hr = acadApp->get_MenuGroups(&mnuGrps);
    if (FAILED(hr))
    {
        acadApp->Release();
        return false;
    }
    mnuGrps->get_Count(&cnt);


    //get AutoCAD menu group. say it is index 0.
    IAcadMenuGroup *mnuGrp = NULL;

    VARIANT  vtName;
    vtName.vt = VT_I4;
    BSTR  grpName;
    bool found = false ;
    for (long i=0; i < cnt; i++)
    {
        vtName.lVal = i;
        hr = mnuGrps->Item(vtName, &mnuGrp);
        if (FAILED(hr))
            return false;


        hr  = mnuGrp->get_Name(&grpName);
        CString cgrpName(grpName);
        if (cgrpName.CompareNoCase("Acad")==0)
        {
            found = true;
            *pVal = mnuGrp;
            break;
        }
    }

    acadApp->Release();
    return found;
}
Esempio n. 9
0
LPDISPATCH Change::GetDocument()
{
	LPDISPATCH lpDisp = NULL;
	lpDisp = (LPDISPATCH)m_pDoc->GetInterface(&IID_IDispatch);
	
	if (lpDisp)
		lpDisp->AddRef();
	
	return lpDisp;
}
Esempio n. 10
0
void CNetscapeCntrItem::OnActivate()
{
	char * pSource = NULL;
	const char* ptr;
	LPDISPATCH pdisp;
	HRESULT hr;
	int _convert;
	if (m_lpObject->QueryInterface(IID_IDispatch, (void**)&pdisp) == S_OK){
#ifdef XP_WIN32
		LPCOLESTR lpOleStr = T2COLE("SaveAs");
		hr = pdisp->GetIDsOfNames(IID_NULL, (unsigned short **)&lpOleStr, 1, LOCALE_USER_DEFAULT, &m_idSavedAs);
		pdisp->Release();
		if (hr == S_OK)	
			m_bCanSavedByOLE = TRUE;
		else
			m_idSavedAs = DISPID_UNKNOWN;
#else
			m_idSavedAs = DISPID_UNKNOWN;
#endif
	}

	const char* ptr1 = m_csAddress; 
	if (NET_IsLocalFileURL((char*)ptr1)) {
		XP_ConvertUrlToLocalFile(m_csAddress, &pSource);
		m_csDosName = *pSource;  // pick up the drive name.
		m_csDosName += ":";
		m_csDosName += strchr(pSource, '\\');  // pick up the real file name.
		ptr = m_csDosName;	 
		FE_ConvertSpace((char*)ptr);
		XP_FREE(pSource);
	}

	// the object does not support ole automation, try to find out if this is a storagefile, so
	// we can use OLESave().
	if (!m_bCanSavedByOLE) {
#ifdef XP_WIN32		// we will only want to handle saving when the object had storage file.
		int _convert;
		LPCOLESTR lpsz = A2CW(m_csDosName);
		if (StgIsStorageFile(lpsz) == S_OK) 
			m_bCanSavedByOLE = TRUE;
#else                       
		HRESULT sc1 = StgIsStorageFile(m_csDosName);
		if (GetScode(sc1) == S_OK) 
			m_bCanSavedByOLE = TRUE;
#endif
		}

	CGenericView* pView = GetActiveView();
	CFrameGlue *pFrameGlue = pView->GetFrame();
	if(pFrameGlue != NULL)	{
		m_bLocationBarShowing = pFrameGlue->GetChrome()->GetToolbarVisible(ID_LOCATION_TOOLBAR);
	}

	COleClientItem::OnActivate();
}
Esempio n. 11
0
// The open document event handle is the place where the real interface work
// is done.
// Vim gets called from here.
//
HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument)
{
	AFX_MANAGE_STATE (AfxGetStaticModuleState ());

	if (! g_bEnableVim)
		// Vim not enabled or empty command line entered
		return S_OK;

	// First get the current file name and line number

	// Get the document object
	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
	if (! pDoc)
		return S_OK;

	BSTR FileName;
	long LineNr = -1;

	// Get the document name
	if (FAILED (pDoc->get_FullName (&FileName)))
		return S_OK;

	LPDISPATCH pDispSel;

	// Get a selection object dispatch pointer
	if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
	{
		// Get the selection object
		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);

		if (pSel)
			// Get the selection line number
			pSel->get_CurrentLine (&LineNr);

		pDispSel->Release ();
	}

	// Open the file in Vim and position to the current line
	if (VimOpenFile (FileName, LineNr))
	{
		if (! g_bDevStudioEditor)
		{
			// Close the document in developer studio
			CComVariant vSaveChanges = dsSaveChangesPrompt;
			DsSaveStatus Saved;

			pDoc->Close (vSaveChanges, &Saved);
		}
	}

	// We're done here
	SysFreeString (FileName);
	return S_OK;
}
// MyTimerProc is a callback function passed to SetTimer()
VOID CALLBACK MyTimerProc(HWND /*hwnd*/, UINT /*uMsg*/, UINT /*idEvent*/, 
   DWORD /*dwTime*/)
{
   LPDISPATCH pDisp = NULL;
   // gpMyCtrl is a global variable of type CMyCtrl*
   // _GetEntries() is a static function you get with BEGIN_COM_MAP()
   AtlInternalQueryInterface (gpMyCtrl, CMyCtrl::_GetEntries(), IID_IDispatch, 
      (LPVOID*)&pDisp);
   //...
   pDisp->Release ();
}
Esempio n. 13
0
IHTMLDocument2Ptr CH_HBarWnd::GetHtmlDocument(){
  LPDISPATCH pDispatch = 0;
  if(pwb_){
    if (FAILED(pwb_->get_Document(&pDispatch))){
      return NULL;
    }
  }
  IHTMLDocument2Ptr pHtmlDoc2 = pDispatch;
  if(pDispatch)
    pDispatch->Release();
  return pHtmlDoc2;
}
Esempio n. 14
0
bool ArxToolBar::GetAcadApplication( IAcadApplication*& pAcadApp )
{
    LPDISPATCH  pDisp = NULL;

    if ( !GetAcadApplication( &pDisp ) )
        return false;

    HRESULT hr = S_OK;
    hr = pDisp->QueryInterface( IID_IAcadApplication, ( LPVOID* )&pAcadApp );
    if ( FAILED( hr ) )
        return false;

    return true;
}
Esempio n. 15
0
const COleDispatchDriver&
COleDispatchDriver::operator=(const COleDispatchDriver& dispatchSrc)
{
	if (this != &dispatchSrc)
	{
		LPDISPATCH lpTemp = m_lpDispatch;
		m_lpDispatch = dispatchSrc.m_lpDispatch;
		if (m_lpDispatch != NULL)
			m_lpDispatch->AddRef();
		if (lpTemp != NULL && m_bAutoRelease)
			lpTemp->Release();
		m_bAutoRelease = TRUE;
	}
	return *this;
}
Esempio n. 16
0
void CHTMLViewCapView::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
	UNUSED_ALWAYS(pDisp);
	UNUSED_ALWAYS(URL);

	HRESULT hr;
	IUnknown* pUnkBrowser = NULL;
    IUnknown* pUnkDisp = NULL;

	// 这个 DocumentComplete 事件是否是顶层框架窗口的?
    // 检查 COM 标识: 比较IUnknown 接口指针.
	hr = m_pBrowserApp->QueryInterface(IID_IUnknown, (void**)&pUnkBrowser);

	if ( SUCCEEDED(hr) ) {
		hr = pDisp->QueryInterface(IID_IUnknown,  (void**)&pUnkDisp);

		if ( SUCCEEDED(hr) ) {
			if ( pUnkBrowser == pUnkDisp ) {
				TRACE("Top Document completely loaded!\n");
				EndModalLoop(S_OK);
				//::SetEvent(m_hDocCompleteEvent);
			}
		}

		pUnkDisp->Release();
	}
	pUnkBrowser->Release();
}
Esempio n. 17
0
// Get IHTMLDocument2
CComPtr<IHTMLDocument2> FW_HtmlCtrl::GetHTMLDocument2()
{
	if(!m_spHTMLDocument2)
	{
		LPDISPATCH pDisp = GetContainer();
		if(pDisp)
		{
			IHTMLDocument2* pHTMLDocument2 = NULL;
			HRESULT hr = pDisp->QueryInterface(__uuidof(IHTMLDocument2), (void**)&pHTMLDocument2);
			if(SUCCEEDED(hr))
				m_spHTMLDocument2.Attach(pHTMLDocument2);
		}
	}

	return m_spHTMLDocument2;
}
void CThingTreeCtrl::SelectThing(LPDISPATCH Thing) 
{
	IThing *pCurrentThing = NULL;
	HRESULT hr = S_OK;
	long lCurrentID;
	HTREEITEM htItem = NULL;

	if (FAILED(hr = Thing->QueryInterface(IID_IThing, (void**)&pCurrentThing)))
		goto exit;

	if(pCurrentThing)
	{
		if (FAILED(hr = pCurrentThing->get_ID(&lCurrentID)))
			goto exit;

		// Search for the htreeitem that corresponds these ids
		htItem = InTree(m_hRoom, lCurrentID);

		// if we found the item, select it and exit
		if(htItem)
		{
			// TODO - Make sure this doesn send a TVN_SELCHANGED notification!!!!
			// It does, so we have to regulate it with a bool
			m_bSelectedByMe = FALSE;
			m_treeCtrl.SelectItem(htItem);
		}
	}

exit:

	SAFERELEASE(pCurrentThing);
}
Esempio n. 19
0
void CEx24dView::OnDlloleLoad() 
{
   if(!m_auto.CreateDispatch("Ex24b.Auto")) {
		AfxMessageBox("Ex24b.Auto component not found");
		return;
   }
   m_auto.SetTextData(COleVariant("test"));  // testing
   m_auto.SetLongData(79);  // testing
	// verify dispatch interface
    // {A9515AD7-5B85-11D0-848F-00400526305B}
	static const IID IID_IEx24bAuto =
	{ 0xa9515ad7, 0x5b85, 0x11d0, { 0x84, 0x8f, 0x0, 0x40, 0x5, 0x26, 0x30, 0x5b } };
	LPDISPATCH p;
	HRESULT hr = m_auto.m_lpDispatch->QueryInterface(IID_IEx24bAuto, 
		(void**) &p);
	TRACE("OnDlloleLoad -- QueryInterface result = %x\n", hr);
	p->Release();
}
Esempio n. 20
0
/*  CreateUser()   - Function for creating a basic User
    
    Parameters

        IDirectoryObject *pDirObject    -   Parent Directory Object for the new User
        LPWSTR pwCommonName             -   Common Name for the new User
        IDirectoryObject ** ppDirObjRet -   Pointer to the Pointer which will receive the new User
        int iUserType                  -   Bitflags for new User:
                                                                    ADS_User_TYPE_GLOBAL_User, 
                                                                    ADS_User_TYPE_DOMAIN_LOCAL_User, 
                                                                    ADS_User_TYPE_UNIVERSAL_User, 
                                                                    ADS_User_TYPE_SECURITY_ENABLED 
*/
HRESULT CreateUser(IDirectoryObject *pDirObject, LPWSTR pwCommonName,LPWSTR pwSamAcctName,IDirectoryObject ** ppDirObjRet)
{
    assert(pDirObject);
    if (wcslen(pwSamAcctName) >20)
    {
        MessageBox(NULL,L"SamAccountName CANNOT be bigger than 20 characters",L"Error: CreateSimpleUser()",MB_ICONSTOP);
        assert(0);
        return E_FAIL;
    }

	HRESULT    hr;
    ADSVALUE   sAMValue;
    ADSVALUE   classValue;
    LPDISPATCH pDisp;
    WCHAR       pwCommonNameFull[1024];
    
    ADS_ATTR_INFO  attrInfo[] = 
    {  
       { L"objectClass", ADS_ATTR_UPDATE, 
                           ADSTYPE_CASE_IGNORE_STRING, &classValue, 1 },
       {L"sAMAccountName", ADS_ATTR_UPDATE, 
                           ADSTYPE_CASE_IGNORE_STRING, &sAMValue, 1},
    };

    DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO); 
    classValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
    classValue.CaseIgnoreString = L"User";
   
    sAMValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
    sAMValue.CaseIgnoreString = pwSamAcctName;
 
    wsprintfW(pwCommonNameFull,L"CN=%s",pwCommonName);
     
    hr = pDirObject->CreateDSObject( pwCommonNameFull,  attrInfo, 
                                dwAttrs, &pDisp );
    if (SUCCEEDED(hr))
    {
        hr = pDisp->QueryInterface(IID_IDirectoryObject,(void**) ppDirObjRet);

        pDisp->Release();
        pDisp = NULL;
    }
    return hr;
}
Esempio n. 21
0
void
run_explorer_revert_folder (LPDISPATCH button)
{
  LPDISPATCH obj;

  log_debug ("%s:%s: Enter", SRCNAME, __func__);

  /* Notify the user that the general GpgOl function will be disabled
     when calling this function.  */
  if ( opt.disable_gpgol
       || (MessageBox 
           (NULL/* FIXME: need the hwnd */,
            _("You are about to start the process of reversing messages "
              "created by GpgOL to prepare deinstalling of GpgOL. "
              "Running this command will put GpgOL into a disabled state "
              "so that messages are not anymore processed by GpgOL.\n"
              "\n"
              "You should convert all folders one after the other with "
              "this command, close Outlook and then deinstall GpgOL.\n"
              "\n"
              "Note that if you start Outlook again with GpgOL still "
              "being installed, GpgOL will again process messages."),
            _("GpgOL"), MB_ICONWARNING|MB_OKCANCEL) == IDOK))
    {
      if ( MessageBox 
           (NULL /* Fixme: need hwnd */,
            _("Do you want to revert this folder?"),
            _("GpgOL"), MB_ICONQUESTION|MB_YESNO) == IDYES )
        {
          if (!opt.disable_gpgol)
            opt.disable_gpgol = 1;

          obj = get_oom_object (button, 
                                "get_Parent.get_Parent.get_Parent.get_Parent"
                                ".get_CurrentFolder");
          if (obj)
            {
              gpgol_folder_revert (obj);
              obj->Release ();
            }
        }
    }
}
Esempio n. 22
0
/* Check whether we are in composer or read mode.  */
static bool
is_inspector_in_composer_mode (LPDISPATCH inspector)
{
  LPDISPATCH obj;
  bool in_composer;
  
  obj = get_oom_object (inspector, "get_CurrentItem");
  if (obj)
    {
      /* We are in composer mode if the "Sent" property is false and
         the class is 43.  */
      in_composer = (!get_oom_bool (obj, "Sent") 
                     && get_oom_int (obj, "Class") == 43);
      obj->Release ();
    }
  else
    in_composer = false;
  return in_composer;
}
Esempio n. 23
0
HRESULT WSAccessor::AutoDispInvoke(LPDISPATCH pdisp, LPOLESTR pwszname, DISPID dspid,
					WORD wflags, DWORD cargs, VARIANT* rgargs, VARIANT* pvtret)
{
    HRESULT    hr;
    DISPID     dspidPut = DISPID_PROPERTYPUT;
    DISPPARAMS dspparm = {NULL, NULL, 0, 0};

	CHECK_NULL_RETURN(pdisp, E_POINTER);

    dspparm.rgvarg = rgargs;
    dspparm.cArgs = cargs;

	if ((wflags & DISPATCH_PROPERTYPUT) || (wflags & DISPATCH_PROPERTYPUTREF))
	{
		dspparm.rgdispidNamedArgs = &dspidPut;
		dspparm.cNamedArgs = 1;
	}

	try
	{
		if (pwszname)
		{
			hr = pdisp->GetIDsOfNames(IID_NULL, &pwszname, 1, LOCALE_USER_DEFAULT, &dspid);
			//RETURN_ON_FAILURE(hr);
			if( FAILED(hr))
			{
				*(_variant_t*)pvtret = L"方法名获取失败,可能拼写错误!";
				return hr;
			}
		}

        hr = pdisp->Invoke(dspid, IID_NULL, LOCALE_USER_DEFAULT,
            (WORD)(DISPATCH_METHOD | wflags), &dspparm, pvtret, NULL, NULL);

    }
    catch(...)
    {
        hr = S_FALSE;
    }

    return hr;
}
Esempio n. 24
0
//
// Function: LoadWebOCFromStream
//
// Description: Takes an IWebBrowser pointer and causes the stream to 
// be loaded into the contained HTML Document Object.
//
HRESULT LoadWebOCFromStream(IWebBrowser *pWebBrowser, IStream *pStream)
{
    HRESULT             hr;
    LPDISPATCH          pHtmlDoc = NULL;
    IPersistStreamInit *pPersistStreamInit = NULL;

    // Test for valid pointers.
    //
    if (!pWebBrowser || !pStream)
        return E_POINTER;

    // Get to the document object's IDispatch pointer.
    //
    hr = pWebBrowser->get_Document(&pHtmlDoc);
    if (hr)
        goto CleanUp;

    // Query for IPersistStreamInit
    //
    hr = pHtmlDoc->QueryInterface(IID_IPersistStreamInit, 
            (void**)&pPersistStreamInit);
    if (hr)
        goto CleanUp;

    // Tell the document we'll be reinitializing it.
    //
    hr = pPersistStreamInit->InitNew();
    if (hr)
        goto CleanUp;

    // Load the contents of the stream.
    //
    hr = pPersistStreamInit->Load(pStream);

CleanUp:
    if (pHtmlDoc)
        pHtmlDoc->Release();
    if (pPersistStreamInit)
        pPersistStreamInit->Release();
    return hr;

}
Esempio n. 25
0
/* Search through all objects and find the inspector which has a
   the window handle HWND.  Returns NULL if not found.  */
LPDISPATCH
get_inspector_from_hwnd (HWND hwnd)
{
  LPDISPATCH result = NULL;
  inspector_info_t iinfo;

  lock_all_inspectors ();

  for (iinfo = all_inspectors; iinfo; iinfo = iinfo->next)
    if (iinfo->hwnd == hwnd)
        {
          result = iinfo->inspector;
          if (result)
            result->AddRef ();
          break;
        }
  
  unlock_all_inspectors ();
  return result;
}
Esempio n. 26
0
void CChatView::OnDocumentComplete(LPCTSTR lpszURL) 
{
	// show html on first loading of document
	if(m_bMemoryMode)
	{
		LPDISPATCH lpDispatch;
		lpDispatch=GetHtmlDocument();
		ASSERT(lpDispatch);

		//get html document from IDispatch
		HRESULT hr=lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&m_pHtmlDoc2);
		if( SUCCEEDED(hr)) 
			ShowMemoryHtml();

		// get the parent window
		m_pHtmlDoc2->get_parentWindow( &m_pParentWindow );
	}

	CHtmlView::OnDocumentComplete(lpszURL);
}
Esempio n. 27
0
static int
set_one_button (LPDISPATCH inspector, const char *tag, bool down)
{
  LPDISPATCH button;
  int rc = 0;

  button = get_button (inspector, tag);
  if (!button)
    {
      log_error ("%s:%s: `%s' not found", SRCNAME, __func__, tag);
      rc = -1;
    }
  else
    {
      if (put_oom_int (button, "State", down? msoButtonDown : msoButtonUp))
        rc = -1;
      button->Release ();
    }
  return rc;
}
Esempio n. 28
0
GpgolInspectorEvents::Activate (void)
{
  LPOOMINSPECTOR inspector;
  LPDISPATCH obj;

  log_debug ("%s:%s: Called (this=%p, inspector=%p)", 
             SRCNAME, __func__, this, m_object);
  
  /* Note: It is easier to use the registered inspector object than to
     find the inspector object in the ALL_INSPECTORS list.  The
     ALL_INSPECTORS list primarly useful to keep track of additional
     information, not directly related to the event sink. */
  if (!m_object)
    {
      log_error ("%s:%s: Object not set", SRCNAME, __func__);
      return;
    }
  inspector = (LPOOMINSPECTOR)m_object;
  inspector->AddRef ();

  /* If this is the first activate for the inspector, we add the
     controls.  We do it only now to be sure that everything has been
     initialized.  Doing that in GpgolInspectorsEvents::NewInspector
     is not suggested due to claims from some mailing lists.  */ 
  if (!m_first_activate_seen)
    {
      m_first_activate_seen = true;
      add_inspector_controls (inspector);
      obj = get_oom_object (inspector, "get_CurrentItem");
      if (obj)
        {
          // LPDISPATCH obj2 = install_GpgolItemEvents_sink (obj);
          // if (obj2)
          //   obj2->Release ();
          obj->Release ();
        }
    }
  
  update_crypto_info (inspector);
  inspector->Release ();
}
void CGraphConstructionForm::Reload(GraphStudio::RenderParameters *params)
{
	CString		text;
	GenerateHTML(text, params);

	LPDISPATCH		doc = browser_window.get_Document();
	if (doc) {
		CComPtr<IHTMLDocument2>	html;
		doc->QueryInterface(IID_IHTMLDocument2, (void**)&html);
		if (html) {

			CComBSTR    bstrURL;
			CComVariant varDummy;

			html->open(bstrURL, CComVariant("_self"), varDummy, varDummy, NULL);

			// Create a safearray to store the HTML text
			SAFEARRAY      *pSA = NULL;
			SAFEARRAYBOUND  saBound = {1, 0};
			pSA = SafeArrayCreate(VT_VARIANT, 1, &saBound);
			if (pSA) {

				// Copy the HTML into the one and only element
				VARIANT   *pVar;	
				SafeArrayAccessData(pSA, (void**)&pVar);    // Access safearray data

				V_BSTR(pVar)	= SysAllocString(text);
				V_VT(pVar)		= VT_BSTR;

				SafeArrayUnaccessData(pSA);                 // Release access
				// Write the HTML as the document's new text
				html->write(pSA);                           // Overwrite HTML
				SafeArrayDestroy(pSA);                      // Finished with the safearray
			}

			html->close();  
		}
		doc->Release();
	}	
}
Esempio n. 30
0
/* The method called by outlook for each new inspector.  Note that
   Outlook sometimes reuses Inspectro objects thus this event is not
   an indication for a newly opened Inspector.  */
STDMETHODIMP
GpgolInspectorsEvents::NewInspector (LPOOMINSPECTOR inspector)
{
  LPDISPATCH obj;

  log_debug ("%s:%s: Called (this=%p, inspector=%p)",
             SRCNAME, __func__, this, inspector);

  /* It has been said that INSPECTOR here a "weak" reference. This may
     mean that the object has not been fully initialized.  So better
     take some care here and also take an additional reference.  */

  inspector->AddRef ();
  obj = install_GpgolInspectorEvents_sink ((LPDISPATCH)inspector);
  if (obj)
    {
      register_inspector ((LPGPGOLINSPECTOREVENTS)obj, inspector);
      obj->Release ();
    }
  inspector->Release ();
  return S_OK;
}