CDlgIADsPropertyList::CDlgIADsPropertyList(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
    : CDialog(CDlgIADsPropertyList::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDlgIADsPropertyList)
    m_sAttribute = _T("");
    //}}AFX_DATA_INIT

    HRESULT hr;
    m_pPropList = NULL;
    hr = pUnk->QueryInterface( IID_IADsPropertyList, (void **) &m_pPropList );
    if ( !SUCCEEDED(hr) )
    {
        AfxMessageBox(_T("Fatal Error! QI for IADsPropertyList failed"));
        return;
    }
    pUnk->Release();


    //////////////////////////////////////////
    // Retrieve the data to the cache
    ////////////////////////////////////////////
    IADs *pADs=NULL;
    hr = m_pPropList->QueryInterface( IID_IADs, (void**) &pADs );
    if ( SUCCEEDED(hr) )
    {
        hr = pADs->GetInfo();
        pADs->Release();
    }



}
CDlgIDirectoryObject::CDlgIDirectoryObject(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDirectoryObject::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDirectoryObject)
	m_sDN = _T("");
	m_sRDN = _T("");
	m_sSchema = _T("");
	m_sClass = _T("");
	m_sParent = _T("");
	m_sAttributes = _T("");
	//}}AFX_DATA_INIT

	HRESULT hr;
	m_pDirObject = NULL;
	hr = pUnk->QueryInterface( IID_IDirectoryObject, (void **) &m_pDirObject );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IDirectoryObject failed"));
		return;
	}
	pUnk->Release();

	ShowAttributes();

}
示例#3
0
CDlgIADs::CDlgIADs(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIADs::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIADs)
	m_sADsPath = _T("");
	m_sClass = _T("");
	m_sName = _T("");
	m_sParent = _T("");
	m_sSchema = _T("");
	m_sGUID = _T("");
	//}}AFX_DATA_INIT

	///////////////////////////////////////
	// Get the IADs pointer and save it 
	/////////////////////////////////////
	HRESULT hr;
	m_pADs = NULL;
	hr = pUnk->QueryInterface( IID_IADs, (void **) &m_pADs );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IADs failed"));
		return;
	}
	pUnk->Release();
	

}
int CTemplateWizardDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (TEMPLATE_WIZARD_DIALOG::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	AfxEnableControlContainer();

	// create the control window
	// AFX_IDW_PANE_FIRST is a safe but arbitrary ID
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, "",
				WS_VISIBLE | WS_CHILD, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST))
	{
		DestroyWindow();
		return FALSE;
	}

	LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown();
	HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp);
	if (!SUCCEEDED(hr))
	{
		m_pBrowserApp = NULL;
		m_wndBrowser.DestroyWindow();
		DestroyWindow();
		return FALSE;
	}

	return 0;
}
示例#5
0
FARINTERNAL_(BOOL) UtGetClassID(LPUNKNOWN lpUnk, CLSID FAR* lpClsid)
{
	VDATEHEAP();

	LPOLEOBJECT lpOleObj; // IOleObject pointer
	LPPERSIST lpPersist; // IPersist pointer

	// try to ask it as an object
	if (lpUnk->QueryInterface(IID_IOleObject,
			(LPLPVOID)&lpOleObj) == NOERROR)
	{
		lpOleObj->GetUserClassID(lpClsid);
		lpOleObj->Release();
		return(TRUE);
	}       
	
	// try to ask it as a persistent object
	if (lpUnk->QueryInterface(IID_IPersist,
			(LPLPVOID)&lpPersist) == NOERROR)
	{
		lpPersist->GetClassID(lpClsid);
		lpPersist->Release();
		return(TRUE);
	}
	
	*lpClsid = CLSID_NULL;
	return(FALSE);
}
CDlgIDirectorySearch::CDlgIDirectorySearch(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDirectorySearch::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDirectorySearch)
	m_sFilter = _T("");
	m_bEnableFilter = FALSE;
	m_nTimeOut = 0;
	m_bCacheResult = FALSE;
	m_nPageSize = 0;
	m_sSortOn = _T("");
	m_nTimeLimit = 0;
	m_nSizeLimit = 0;
	m_bAsynch = FALSE;
	m_bAttrib = FALSE;
	m_nDeref = -1;
	//}}AFX_DATA_INIT
	HRESULT hr;
	m_pSearch = NULL;
	hr = pUnk->QueryInterface( IID_IDirectorySearch, (void **) &m_pSearch );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IDirectorySearch failed"));
		return;
	}
	pUnk->Release();



}
void CADQIDlg::EnumerateInterface()
{
    int xx=0;
    HRESULT hr;
    LPUNKNOWN pQI;

    m_cListIf.ResetContent();

    ///////////////////////////////////////////////////////////////
    // Query Interface all known ADSI Interfaces
    ////////////////////////////////////////////////////////////////
    while( !IsEqualIID( *adsiIfs[xx].pIID, IID_NULL ) )
    {
        hr = m_pUnk->QueryInterface( *adsiIfs[xx].pIID, (void**) &pQI );
        if ( SUCCEEDED(hr) )
        {
            m_cListIf.AddString( adsiIfs[xx].szIf );
            pQI->Release();
        }
        xx++;
    }



}
示例#8
0
STDMETHODIMP CIEControlSite::XDocHostUIHandler::ShowContextMenu(
    DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdTarget, LPDISPATCH pdispReserved)
{
    METHOD_PROLOGUE_EX_(CIEControlSite, DocHostUIHandler);
    return S_FALSE;

    // 点击右键添加到收藏夹
    HWND hwnd;
    CComPtr<IOleCommandTarget> spCT;
    CComPtr<IOleWindow> spWnd;

    HRESULT hr = pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&spCT);
    if ( FAILED(hr) )
        return S_FALSE;

    hr = pcmdTarget->QueryInterface(IID_IOleWindow, (void**)&spWnd);
    if ( FAILED(hr) )
        return S_FALSE;

    hr = spWnd->GetWindow(&hwnd);

#define ID_IE_ID_ADDFAV 2261
    ::SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(LOWORD(ID_IE_ID_ADDFAV), 0x0), 0 );

    return S_OK;
}
示例#9
0
STDMETHODIMP ActiveScriptImpl::GetItemInfo(
			/* [in] */ LPCOLESTR pstrName,
			/* [in] */ DWORD dwReturnMask,
			/* [out] */LPUNKNOWN* ppiunkItem,
			/* [out] */LPTYPEINFO* ppti)
{
	if (dwReturnMask & SCRIPTINFO_ITYPEINFO)
	{
		if (!ppti)
			return E_INVALIDARG;
		*ppti = NULL;
	}

	if (dwReturnMask & SCRIPTINFO_IUNKNOWN)
	{
		if (!ppiunkItem)
			return E_INVALIDARG;
		*ppiunkItem = NULL;
	}

	LPUNKNOWN lpUnknown = namedItems.get(pstrName);
	if (NULL == lpUnknown)
	{
		ATLTRACE("No IUnknown for item!\n");
		// This shouldn't ever happen, since we're providing the items
		return TYPE_E_ELEMENTNOTFOUND;
	}

	if (dwReturnMask & SCRIPTINFO_ITYPEINFO)
	{
		// Use IProvideClassInfo to get ITypeInfo of coclass!
		IProvideClassInfo *pci = NULL;
		HRESULT hr = lpUnknown->QueryInterface(IID_IProvideClassInfo, (void**)&pci);
		if (SUCCEEDED(hr) && pci)
		{
			hr = pci->GetClassInfo(ppti);
		}

		// Release interface
		if (pci)
			pci->Release();

		if (FAILED(hr))
			return E_FAIL;
	}

	if (dwReturnMask & SCRIPTINFO_IUNKNOWN)
	{
		*ppiunkItem = lpUnknown;
		int *pInt = weakItems.get(pstrName);
		if (!pInt)
			(*ppiunkItem)->AddRef();    // because returning
		else
			*pInt = (*pInt) + 1;
	}

	return S_OK;
}
示例#10
0
BOOL CSignalDefinerDlg::OnInitDialog()
{
    CDialog::OnInitDialog();


    UpdateData(FALSE);
    m_ctrNoOfCycles.SetCurSel(m_nSelCycle);

    //Get the CWnd reference to the DMGraph ActiveX control
    m_poDMGraphCtrl = GetDlgItem(IDC_DMGRAPHCTRL);

    /*Set Graph properties*/
    if( m_poDMGraphCtrl->m_hWnd != NULL )
    {
        LPUNKNOWN pUnk = m_poDMGraphCtrl->GetControlUnknown();
        IDMGraphCtrl* pDMGraphCtrl = NULL;

        pUnk->QueryInterface(IID_IDMGraphCtrl, (void**) &pDMGraphCtrl);
        if (  pDMGraphCtrl ==NULL )
        {
            return TRUE;
        }
        // Set Axis Color
        pDMGraphCtrl->put_AxisColor((OLE_COLOR)0xFF);
        // Set Plot Area Color
        pDMGraphCtrl->put_PlotAreaColor((OLE_COLOR)0x00);
        // Set Grid Color
        pDMGraphCtrl->put_GridColor((OLE_COLOR)0xC0C0C0);
        // Set Frame Style
        pDMGraphCtrl->put_FrameStyle((FrameStyle)1);
        // Set Frame Color
        pDMGraphCtrl->put_ControlFrameColor((OLE_COLOR)0x5500);

        // Set Grid Lines Count
        CComPtr<IDMGraphAxis> spAxisX;
        pDMGraphCtrl->get_Axis( HorizontalX, &spAxisX);
        spAxisX->put_GridNumber(10);

        CComPtr<IDMGraphAxis> spAxisY;
        pDMGraphCtrl->get_Axis( VerticalY, &spAxisY);
        spAxisY->put_GridNumber(5);

        if (NULL != pDMGraphCtrl)
        {
            pDMGraphCtrl->Release();
            pDMGraphCtrl = NULL;
        }
    }

    vGenerateWave();


    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
示例#11
0
文件: oledll.cpp 项目: shuowen/OpenNT
SCODE AFXAPI AfxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    SCODE sc;
    *ppv = NULL;

    AFX_OLE_STATE* pOleState = AfxGetOleState();
    // search factories defined in the application
    for (COleObjectFactory* pFactory = pOleState->m_pFirstFactory;
            pFactory != NULL; pFactory = pFactory->m_pNextFactory)
    {
        if (pFactory->m_dwRegister != 0 && pFactory->m_clsid == rclsid)
        {
            // found suitable class factory -- query for correct interface
            sc = pFactory->ExternalQueryInterface(&riid, ppv);
            if (sc != NOERROR)
                return sc;
#ifndef _UNICODE
            LPUNKNOWN lpUnk = (LPUNKNOWN)*ppv;
            ASSERT(lpUnk != NULL);
            sc = ::Ole2AnsiWFromA(riid, lpUnk, (LPUNKNOWN*)ppv);
            lpUnk->Release();
#endif
            return sc;
        }
    }
#ifdef _AFXDLL
    // search factories defined in extension DLLs
    AFX_CORE_STATE* pCoreState = AfxGetCoreState();
    for (CDynLinkLibrary* pDLL = pCoreState->m_pFirstDLL; pDLL != NULL;
            pDLL = pDLL->m_pNextDLL)
    {
        for (pFactory = pDLL->m_pFirstSharedFactory;
                pFactory != NULL; pFactory = pFactory->m_pNextFactory)
        {
            if (pFactory->m_dwRegister != 0 && pFactory->m_clsid == rclsid)
            {
                // found suitable class factory -- query for correct interface
                sc = pFactory->ExternalQueryInterface(&riid, ppv);
                if (sc != NOERROR)
                    return sc;
#ifndef _UNICODE
                LPUNKNOWN lpUnk = (LPUNKNOWN)*ppv;
                ASSERT(lpUnk != NULL);
                sc = ::Ole2AnsiWFromA(riid, lpUnk, (LPUNKNOWN*)ppv);
                lpUnk->Release();
#endif
                return sc;
            }
        }
    }
#endif

    // factory not registered -- return error
    return CLASS_E_CLASSNOTAVAILABLE;
}
示例#12
0
DLLEXPORT double MADX9_FreePointer(double p)
{
	LPUNKNOWN ptr = (LPUNKNOWN) DoubleToPtr(p);

	if (ptr == 0)
		return ErrorHandle(mamain->err, ErrorInv);

	ptr->Release();

	return ErrorOk;
}
示例#13
0
BOOL CHTMLContainerDlg::OnInitDialog()
{
	AfxEnableControlContainer();

	CDialog::OnInitDialog();

	RECT rectClient;
	GetClientRect(&rectClient);

	// if we've been created from the dynamic template
	// set the caption
	if(!m_lpszTemplateName)
		SetWindowText(m_strDlgCaption);

	// check if there is a browser control on the dialog
	// already
	CWnd *pCtrl = GetDlgItem(AFX_IDC_BROWSER);
	LPUNKNOWN lpUnk;
	if(pCtrl)
	{
		lpUnk = pCtrl->GetControlUnknown();
		if (lpUnk && SUCCEEDED(lpUnk->QueryInterface(IID_IWebBrowser2, (void **) &m_pBrowserApp)))
		{
			m_wndBrowser.Attach(pCtrl->m_hWnd);
			m_bAttachedControl = TRUE;
		}
	}
	if(m_pBrowserApp == NULL)
	{
		// create the control window
		m_wndBrowser.CreateControl(CLSID_WebBrowser, NULL,
			WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDC_BROWSER);
		lpUnk = m_wndBrowser.GetControlUnknown();
		if(FAILED(lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp)))
		{
			m_wndBrowser.DestroyWindow();
			DestroyWindow();
			return TRUE;
		}
	}
	Navigate(m_strURL);

	m_pBrowserApp->put_Silent(VARIANT_TRUE);//禁止脚本错误提示  
	
	//在不同dpi的情况下,使用相同大小的显示
	if (m_iWidth > 0 && m_iHeight > 0)
	{
		SetWindowPos(NULL, 0, 0, m_iWidth, m_iHeight, SWP_NOMOVE);
	}

	if (m_dialogTitle.GetLength() > 0) SetWindowText(m_dialogTitle);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
示例#14
0
/**
	* OnCreate:
	*
	* @param lpCreateStruct 
	* @return int 
 */
int CToolShell::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if(TRUE == m_wndBrowser.CreateControl(CLSID_WebBrowser, _T("Error"),WS_CHILD | WS_VISIBLE,CRect(0,0,600,300), this, NULL))
	{
		LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown();
		HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp);
	}
	
	return 0;
}
示例#15
0
CConnectionPoint::~CConnectionPoint()
{
	POSITION pos = GetStartPosition();
	while (pos != NULL)
	{
		LPUNKNOWN pUnk = GetNextConnection(pos);
		ASSERT(pUnk != NULL);
		pUnk->Release();
	}

	if (m_pConnections != NULL)
		delete m_pConnections;
}
示例#16
0
////////////////////////////////////////////////
//
// 初始化TOOLTIP控件
//
void CDataGridEx::InitToolTipControl()
{
	if(m_RecordCount<0)
	{
		LPUNKNOWN pUnknown;
		HRESULT hr;
		_RecordsetPtr IRecordset;

		pUnknown=GetDataSource();
		
		if(pUnknown==NULL)
			return;

		try
		{
			hr=pUnknown->QueryInterface(__uuidof(Recordset),(void**)&IRecordset);

			pUnknown->Release();

			if(FAILED(hr))
			{
				throw _com_error(hr);
			}

			m_RecordCount=IRecordset->GetRecordCount();
		}
		catch(_com_error &e)
		{
			AfxMessageBox(e.ErrorMessage());
		}
	}

	if(IsWindow(m_ToolTip.GetSafeHwnd()))
		return;

	m_ToolTip.Create(this);
	
	TOOLINFO ToolInfo;

	memset(&ToolInfo,0,sizeof(TOOLINFO));

	ToolInfo.cbSize=sizeof(TOOLINFO);
	ToolInfo.uFlags=TTF_TRACK|TTF_IDISHWND| TTF_ABSOLUTE;
	ToolInfo.hwnd=this->m_hWnd;
	ToolInfo.uId=(UINT)this->m_hWnd;
	ToolInfo.lpszText=LPSTR_TEXTCALLBACK;

	m_ToolTip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&ToolInfo);
}
示例#17
0
BOOL CDriverDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// create the calculator object that we'll drive through OLE automation
	COleException e;
	CLSID clsid;
	if (CLSIDFromProgID(OLESTR("mfccalc.calculator"), &clsid) != NOERROR)
	{
		AfxMessageBox(IDP_UNABLE_TO_CREATE);
		EndDialog(IDABORT);
		return FALSE;
	}

	// try to get the active calculator before creating a new one
	LPUNKNOWN lpUnk;
	LPDISPATCH lpDispatch;
	if (GetActiveObject(clsid, NULL, &lpUnk) == NOERROR)
	{
		HRESULT hr = lpUnk->QueryInterface(IID_IDispatch,
			(LPVOID*)&lpDispatch);
		lpUnk->Release();
		if (hr == NOERROR)
			m_calc.AttachDispatch(lpDispatch, TRUE);
	}

	// if not dispatch ptr attached yet, need to create one
	if (m_calc.m_lpDispatch == NULL &&
		!m_calc.CreateDispatch(clsid, &e))
	{
		AfxMessageBox(IDP_UNABLE_TO_CREATE);
		EndDialog(IDABORT);
		return FALSE;
	}

	// attempt to make it visible
	m_calc.SetVisible(TRUE);
	if (!m_calc.GetVisible())
	{
		AfxMessageBox(IDP_UNABLE_TO_SHOW);
		EndDialog(IDABORT);
		return FALSE;
	}

	// refresh display to contents of the automation calculator
	OnRefresh();

	return TRUE;  // return TRUE  unless you set the focus to a control
}
示例#18
0
LPUNKNOWN CComObject::GetInterface(REFIID pIID, BOOL bAddRef)
{
	LPUNKNOWN pInterface = CCmdTarget::GetInterface( &pIID );

	if ( ! pInterface && pIID == IID_IDispatch )
	{
		if ( POSITION pos = m_pDispatchMap.GetStartPosition() )
		{
			const IID* pDispIID;
			m_pDispatchMap.GetNextAssoc( pos, pInterface, pDispIID );
		}
	}

	if ( pInterface && bAddRef ) pInterface->AddRef();
	return pInterface;
}
示例#19
0
HRESULT CDataObjectViewer::OnView(HWND hwndParent, REFIID riid, LPUNKNOWN punk)
{
	SCODE sc = NOERROR ;

	ASSERT(hwndParent);
	ENSURE(punk);

	if (riid != IID_IDataObject)
	{
		AfxMessageBox( _T("IDataObject interface viewer only supports IID_IDataObject") ) ;
		return E_INVALIDARG ;
	}

	IDataObject* pdataobj = NULL ;
	sc = punk->QueryInterface( riid, (void**)&pdataobj ) ;
	if (FAILED(sc))
	{
		AfxMessageBox( _T("Object does not support IDataObject") ) ;
		return E_UNEXPECTED ;
	}

	CIDataObjectDlg* pdlg ;
	pdlg = new CIDataObjectDlg( hwndParent, pdataobj, riid, _T("") ) ;

	if (pdlg)
	{
		pdlg->DoModal() ;
		delete pdlg ;
	}

	pdataobj->Release() ;

	return sc ;
}
示例#20
0
void CMFCBindCntrItem::LoadFromMoniker(LPUNKNOWN pUnk, OLECHAR* szwName)
{
	HRESULT hr;
	// Ask the system for a URL Moniker
	IMoniker* pIMoniker;
	hr = CreateURLMoniker(NULL, (LPWSTR)szwName, &pIMoniker);
	if ( SUCCEEDED(hr) )
	{
		// Get the IPersistMoniker interface
		IPersistMoniker* pPMk;
		hr = pUnk->QueryInterface(
								IID_IPersistMoniker,
								(void **)&pPMk);
		if ( SUCCEEDED(hr) )
		{
				// note: do not register our BSC when calling IPM::Load directly
			IBindCtx *pBCtx;
			hr = CreateBindCtx(0, &pBCtx);
			if ( SUCCEEDED(hr) )
			{
				// Call Load on the IPersistMoniker
				hr = pPMk->Load(FALSE, pIMoniker, pBCtx, STGM_READ);
					pBCtx->Release();
			}
			pPMk->Release();
		}
		pIMoniker->Release( );
	}
}
示例#21
0
STDAPI GetInterface(LPUNKNOWN pUnk, void **ppv)
{
    CheckPointer(ppv, E_POINTER);
    *ppv = pUnk;
    pUnk->AddRef();
    return NOERROR;
}
示例#22
0
BOOL AFXAPI _AfxLoadObjectFromStreamedPropset(LPUNKNOWN lpUnknown, LPSTREAM lpStream)
{
	ASSERT_POINTER(lpUnknown, IUnknown);
	ASSERT_POINTER(lpStream, IStream);

	BOOL bSuccess = FALSE;
	LPDATAOBJECT pDataObj = NULL;

	if (SUCCEEDED(lpUnknown->QueryInterface(IID_IDataObject,
			(LPVOID*)&pDataObj)))
	{
		ASSERT_POINTER(pDataObj, IDataObject);

		// Set the persistent propset format on the object.

		FORMATETC formatEtc;
		STGMEDIUM stgMedium;
		formatEtc.cfFormat = _AfxGetClipboardFormatPersistPropset();
		formatEtc.ptd = NULL;
		formatEtc.dwAspect = DVASPECT_CONTENT;
		formatEtc.lindex = -1;
		formatEtc.tymed = TYMED_ISTREAM;

		stgMedium.tymed = TYMED_ISTREAM;
		stgMedium.pstm = lpStream;
		stgMedium.pUnkForRelease = NULL;

		bSuccess = SUCCEEDED(pDataObj->SetData(&formatEtc, &stgMedium, FALSE));

		pDataObj->Release();
	}

	return bSuccess;
}
示例#23
0
void reportError(
	int errorType, LPUNKNOWN pIUnknown, const char * pszMessage )
{
	HRESULT rc;
	assert( pIUnknown != NULL );

	IDgnErrorPtr pIDgnError;
	rc = pIUnknown->QueryInterface(
		__uuidof(IDgnError), (void**)&pIDgnError );
	if( FAILED(rc) )
	{
		reportError( errorType, pszMessage );
		return;
	}

	char szNatSpeakErr[ 512 ];
	DWORD dwSizeNeeded;
	rc = pIDgnError->ErrorMessageGet( szNatSpeakErr, 512, &dwSizeNeeded );
	if( rc != E_BUFFERTOOSMALL && FAILED(rc) )
	{
		reportError( errorType, pszMessage );
		return;
	}

	char szErrorMsg[ 1024 ];
	sprintf( szErrorMsg, "%s (%s)", pszMessage, szNatSpeakErr );
	PyErr_SetString( ErrObjects[errorType], szErrorMsg );
}
/**
 * Function name	CImplMsgSink::UnregisterMsgSource
 * Description			
 * @param			LPUNKNOWN lpUnkMsgSource
 * @param			DWORD dwCookie
 * @return			HRESULT 
 * @exception			
 * @see			    CMsgWnd
*/
HRESULT CImplMsgSink::UnregisterMsgSource(LPUNKNOWN lpUnkMsgSource, DWORD dwCookie) 
{
    ASSERT(lpUnkMsgSource != NULL);

    LPUNKNOWN           pUnkSink;
    BOOL                bResult;

    HRESULT hr = InternalQueryInterface((IID*)&IID_IUnknown, (void**)&pUnkSink);
    if(FAILED(hr)) 
    {
        return(hr);
    }

    bResult = AfxConnectionUnadvise(lpUnkMsgSource, IID__ICEMessageEvent, pUnkSink, TRUE, dwCookie);
    pUnkSink->Release();
    return(bResult ? S_OK : E_FAIL);
}
示例#25
0
BOOL SimpleBrowser::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
    // create browser control window as child of this window; 
	// this window sinks events from control
	//BOOL results = CWnd::Create(AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW),
	//                         NULL,
	//						 dwStyle,
	//						 rect,
	//						 pParentWnd,
	//						 nID);
	BOOL results = CWnd::Create(_T("#32770"),
		NULL,
		dwStyle,
		rect,
		pParentWnd,
		nID);
    if (!results) 
		return FALSE;
	//create the original window
	m_pBrowserWnd = new CWnd;
    results = m_pBrowserWnd->CreateControl(CLSID_WebBrowser, NULL, (WS_VISIBLE | WS_TABSTOP),
		CRect(0,0,rect.right - rect.left,rect.bottom - rect.top), this, AFX_IDW_PANE_FIRST);
    if (!results) 
	{
        DestroyWindow();
        return FALSE;
    }
    // get control interfaces
	m_pBrowser = NULL;
    LPUNKNOWN pUnknown = m_pBrowserWnd->GetControlUnknown();
	HRESULT hr = S_FALSE;
	if (pUnknown != NULL)
	{
		hr = pUnknown->QueryInterface(IID_IWebBrowser2,(void **)&m_pBrowser);
		if (SUCCEEDED(hr)) 
			hr = pUnknown->QueryInterface(IID_IDispatch,(void **)&m_pBrowserDispatch);
	}
    if (!SUCCEEDED(hr)) {
        m_pBrowserWnd->DestroyWindow();
		delete m_pBrowserWnd;
		m_pBrowserWnd = NULL;
        DestroyWindow();
        return FALSE;        
    }
    return TRUE;
}
示例#26
0
文件: oleunk.cpp 项目: Rupan/winscp
LPUNKNOWN AFXAPI _AfxQueryInterface(LPUNKNOWN lpUnknown, REFIID iid)
{
	ASSERT(lpUnknown != NULL);

	LPUNKNOWN lpW = NULL;
	if (lpUnknown->QueryInterface(iid, (LPLP)&lpW) != S_OK)
		return NULL;

	return lpW;
}
示例#27
0
void CBetaPatchClientDlg::CreateWebControl( LPCTSTR szURL )
{
	// AFX_IDW_PANE_FIRST is a safe but arbitrary ID
#ifdef __LANG_JAP
	//JAPAN 패치 클라이언트 이미지 변경관련 웹 크기 조절.	
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, "", WS_VISIBLE | WS_CHILD, CRect(14, 14, 466, 447), 
		this, AFX_IDW_PANE_FIRST))		
#else //__LANG_JAP
#if __CURRENT_LANG == LANG_KOR //공지사항 크기 확장 관련 조정.
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, 
			"",	WS_VISIBLE | WS_CHILD, CRect(26, 190, 452, 447), this, AFX_IDW_PANE_FIRST))
#else //LANG_KOR
	if (!m_wndBrowser.CreateControl(CLSID_WebBrowser, 
		                            "",
				                    WS_VISIBLE | WS_CHILD, 
									CRect(26, 263, 452, 447), 
									this, 
									AFX_IDW_PANE_FIRST))
#endif //LANG_KOR
#endif //__LANG_JAP
	{
		return;
	}

	IWebBrowser2* pBrowser;
	LPUNKNOWN lpUnk = m_wndBrowser.GetControlUnknown();
	HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &pBrowser);
	if (SUCCEEDED(hr))
	{
		CString strURL( szURL );
		BSTR bstrURL = strURL.AllocSysString();

		COleSafeArray vPostData;
		LPCTSTR lpszTargetFrameName = NULL;
		LPCTSTR lpszHeaders = NULL;

		pBrowser->Navigate(bstrURL,
			COleVariant((long) 0, VT_I4),
			COleVariant(lpszTargetFrameName, VT_BSTR),
			vPostData,
			COleVariant(lpszHeaders, VT_BSTR));
	}
}
STDMETHODIMP
CShellExtension::QueryInterface(REFIID riid, LPVOID *ppObj)
{
	*ppObj = 0;
	if (IsEqualIID(riid, IID_IUnknown))
		*ppObj = this;
	else if (IsEqualIID(riid, IID_IShellExtInit))
		*ppObj = (IShellExtInit *)this;
	else if (IsEqualIID(riid, IID_IContextMenu))
		*ppObj = (IContextMenu *)this;

	if (*ppObj) {
		LPUNKNOWN pUnk = (LPUNKNOWN)(*ppObj);
		pUnk->AddRef();
		return S_OK;
	}

	return E_NOINTERFACE;
}
示例#29
0
文件: xarraydb.cpp 项目: DeegC/10d
BOOL IXArrayDB::CreateDispatch(REFCLSID clsid, COleException* pError )
{
   ASSERT(m_lpDispatch == NULL);

   m_bAutoRelease = TRUE;  // good default is to auto-release

   // create an instance of the object
   LPUNKNOWN lpUnknown = NULL;
   HRESULT sc = CreateInstanceLic( this->GetCLSID(), NULL,
                                   CLSCTX_ALL | CLSCTX_REMOTE_SERVER,
                                   IID_IUnknown, (zPVOID*)&lpUnknown);
   if (sc == E_INVALIDARG)
   {
      // may not support CLSCTX_REMOTE_SERVER, so try without
      sc = CreateInstanceLic(this->GetCLSID(), NULL, CLSCTX_ALL & ~CLSCTX_REMOTE_SERVER,
         IID_IUnknown, (zPVOID*)&lpUnknown);
   }
   if (FAILED(sc))
      goto Failed;

   // make sure it is running
   sc = OleRun(lpUnknown);
   if (FAILED(sc))
      goto Failed;

   // query for IDispatch interface
   sc = lpUnknown->QueryInterface( IID_IDispatch, (zPVOID*) &m_lpDispatch);
   if (m_lpDispatch == NULL)
      goto Failed;

   lpUnknown->Release();
   ASSERT(m_lpDispatch != NULL);
   return TRUE;

Failed:
   lpUnknown->Release();
   if (pError != NULL)
      pError->m_sc = sc;
   TRACE1("Warning: CreateDispatch returning scode = %s.\n",
      AfxGetFullScodeString(sc));
   return FALSE;
}
示例#30
0
void VLCConnectionPoint::firePropChangedEvent(DISPID dispId)
{
    map<DWORD,LPUNKNOWN>::iterator end = _connections.end();
    map<DWORD,LPUNKNOWN>::iterator iter = _connections.begin();

    while( iter != end )
    {
        LPUNKNOWN pUnk = iter->second;
        if( NULL != pUnk )
        {
            IPropertyNotifySink *pPropSink;
            if( SUCCEEDED(pUnk->QueryInterface(IID_IPropertyNotifySink, (LPVOID *)&pPropSink)) )
            {
                pPropSink->OnChanged(dispId);
                pPropSink->Release();
            }
        }
        ++iter;
    }
};