Group:  English: Entertainment ยป microsoft.public.windowsmedia.sdk
Thread: _WMPOCXEvents no ATL

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

_WMPOCXEvents no ATL
hlovbeyond 01.07.2007 01:16:00
Hi guys I'm trying to implement _WMPOCXEvents with no ATL but I can't this
work.
I have created CWMPEventListener class which implements _WMPOCXEvents, but
I'm sure I'm missing something, any help will be appreciated
Regards,
HLOV

My code:
I have removed the error checking,

void *pUnknown =NULL;
IWMPPlayer *spPlayer;
CoInitialize(NULL);
HRESULT hr =CoCreateInstance(__uuidof(WindowsMediaPlayer), NULL,
CLSCTX_INPROC_SERVER, __uuidof(spPlayer),(void **)&spPlayer);
IConnectionPoint *m_spConnectionPoint;
IConnectionPointContainer *spConnectionContainer;
hr = spPlayer->QueryInterface(&spConnectionContainer);
hr = spConnectionContainer ->FindConnectionPoint(__uuidof(_WMPOCXEvents),
&m_spConnectionPoint);
_WMPOCXEvents *spEventListener;
CWMPEventListener *pEventListener;
pEventListener->m_pMainDlg=0;

spEventListener = pEventListener;
DWORD m_dwAdviseCookie;
//Program crash in this line
hr = m_spConnectionPoint->Advise(pEventListener, &m_dwAdviseCookie);

CWMPEventListener class:
class CWMPEventListener : public _WMPOCXEvents
{
public:
CWMPEventListener();
virtual ~CWMPEventListener();
int m_pMainDlg;

// IUnknown methods:
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
{
*ppvObject = (void*)this;
return 0;
}

virtual ULONG STDMETHODCALLTYPE AddRef( void)
{
return 1;
}

virtual ULONG STDMETHODCALLTYPE Release( void)
{
return 1;
}


// IDispatch methods:

STDMETHOD(GetIDsOfNames)( REFIID riid,
OLECHAR FAR *FAR *rgszNames,
unsigned int cNames,
LCID lcid,
DISPID FAR *rgDispId )
{
return( E_NOTIMPL );
}

STDMETHOD(GetTypeInfo)( unsigned int iTInfo,
LCID lcid,
ITypeInfo FAR *FAR *ppTInfo )
{
return( E_NOTIMPL );
}

STDMETHOD(GetTypeInfoCount)(unsigned int FAR *pctinfo )
{
return( E_NOTIMPL );
}

STDMETHOD(Invoke)( DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR *pDispParams,
VARIANT FAR *pVarResult,
EXCEPINFO FAR *pExcepInfo,
unsigned int FAR *puArgErr );
};


CWMPEventListener::CWMPEventListener()
{
m_pMainDlg=0;
}

CWMPEventListener::~CWMPEventListener()
{

}

HRESULT CWMPEventListener::Invoke(
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR* pDispParams,
VARIANT FAR* pVarResult,
EXCEPINFO FAR* pExcepInfo,
unsigned int FAR* puArgErr)
{
if (!pDispParams)
return E_POINTER;

if (pDispParams->cNamedArgs != 0)
return DISP_E_NONAMEDARGS;

HRESULT hr = DISP_E_MEMBERNOTFOUND;

switch (dispIdMember)
{
case 10:
//OpenStateChange(pDispParams->rgvarg[0].lVal);
break;
}
return hr;
}

RE: _WMPOCXEvents no ATL
DigiLee 06.07.2007 06:46:01
Hi,

Hi,

I may be missing something, but it seems like in the following section of
your code you are never actually instantiating a CWMPEventListener object.
You are simply defining a pointer to one. Then you assign the pointer and
pass the pointer without having created the object.

I am trying to do something similar. If you solve this, I would appreciate
a peek at the result.

_WMPOCXEvents *spEventListener;
CWMPEventListener *pEventListener; <-- Pointer to CWMPEventListener
pEventListener->m_pMainDlg=0;

spEventListener = pEventListener;
DWORD m_dwAdviseCookie;
//Program crash in this line
hr = m_spConnectionPoint->Advise(pEventListener, &m_dwAdviseCookie);

Good Luck,

Lee


"hlovbeyond" wrote:

[Quoted Text]
> Hi guys I'm trying to implement _WMPOCXEvents with no ATL but I can't this
> work.
> I have created CWMPEventListener class which implements _WMPOCXEvents, but
> I'm sure I'm missing something, any help will be appreciated
> Regards,
> HLOV
>
> My code:
> I have removed the error checking,
>
> void *pUnknown =NULL;
> IWMPPlayer *spPlayer;
> CoInitialize(NULL);
> HRESULT hr =CoCreateInstance(__uuidof(WindowsMediaPlayer), NULL,
> CLSCTX_INPROC_SERVER, __uuidof(spPlayer),(void **)&spPlayer);
> IConnectionPoint *m_spConnectionPoint;
> IConnectionPointContainer *spConnectionContainer;
> hr = spPlayer->QueryInterface(&spConnectionContainer);
> hr = spConnectionContainer ->FindConnectionPoint(__uuidof(_WMPOCXEvents),
> &m_spConnectionPoint);
> _WMPOCXEvents *spEventListener;
> CWMPEventListener *pEventListener;
> pEventListener->m_pMainDlg=0;
>
> spEventListener = pEventListener;
> DWORD m_dwAdviseCookie;
> //Program crash in this line
> hr = m_spConnectionPoint->Advise(pEventListener, &m_dwAdviseCookie);
>
> CWMPEventListener class:
> class CWMPEventListener : public _WMPOCXEvents
> {
> public:
> CWMPEventListener();
> virtual ~CWMPEventListener();
> int m_pMainDlg;
>
> // IUnknown methods:
> virtual HRESULT STDMETHODCALLTYPE QueryInterface(
> /* [in] */ REFIID riid,
> /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
> {
> *ppvObject = (void*)this;
> return 0;
> }
>
> virtual ULONG STDMETHODCALLTYPE AddRef( void)
> {
> return 1;
> }
>
> virtual ULONG STDMETHODCALLTYPE Release( void)
> {
> return 1;
> }
>
>
> // IDispatch methods:
>
> STDMETHOD(GetIDsOfNames)( REFIID riid,
> OLECHAR FAR *FAR *rgszNames,
> unsigned int cNames,
> LCID lcid,
> DISPID FAR *rgDispId )
> {
> return( E_NOTIMPL );
> }
>
> STDMETHOD(GetTypeInfo)( unsigned int iTInfo,
> LCID lcid,
> ITypeInfo FAR *FAR *ppTInfo )
> {
> return( E_NOTIMPL );
> }
>
> STDMETHOD(GetTypeInfoCount)(unsigned int FAR *pctinfo )
> {
> return( E_NOTIMPL );
> }
>
> STDMETHOD(Invoke)( DISPID dispIdMember,
> REFIID riid,
> LCID lcid,
> WORD wFlags,
> DISPPARAMS FAR *pDispParams,
> VARIANT FAR *pVarResult,
> EXCEPINFO FAR *pExcepInfo,
> unsigned int FAR *puArgErr );
> };
>
>
> CWMPEventListener::CWMPEventListener()
> {
> m_pMainDlg=0;
> }
>
> CWMPEventListener::~CWMPEventListener()
> {
>
> }
>
> HRESULT CWMPEventListener::Invoke(
> DISPID dispIdMember,
> REFIID riid,
> LCID lcid,
> WORD wFlags,
> DISPPARAMS FAR* pDispParams,
> VARIANT FAR* pVarResult,
> EXCEPINFO FAR* pExcepInfo,
> unsigned int FAR* puArgErr)
> {
> if (!pDispParams)
> return E_POINTER;
>
> if (pDispParams->cNamedArgs != 0)
> return DISP_E_NONAMEDARGS;
>
> HRESULT hr = DISP_E_MEMBERNOTFOUND;
>
> switch (dispIdMember)
> {
> case 10:
> //OpenStateChange(pDispParams->rgvarg[0].lVal);
> break;
> }
> return hr;
> }
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net