IBurnCallbacks declaration and usage

vbimport

#1

hi,

i’m working on a project using the nerocbui library and I’m new on ATL programming

in order to react on the phases of the burn process i want to use the IBurnCallbacks interface.

is there anyone who can help me to declare a CComQIPtr to this interface?

i tried this:

CComQIPtr<IBurnCallbacks> pBurnCallbacks;

this always leads to a NULL pointer for pBurnCallbacks and the burning related interface methods i.e.OnDoneBurn(…), are not called.

If i’m totally on a wrong way, please give me some code snippet how to use the interface correctly.

thanks in advance, puppy


#2

is there anyone who can help me to declare a CComQIPtr to this interface?

i tried this:

CComQIPtr<IBURNCALLBACKS> pBurnCallbacks;

this always leads to a NULL pointer for pBurnCallbacks and the burning related interface methods i.e.OnDoneBurn(…), are not called.
IBurnCallbacks is an interface which you must implement if you want to receive events during the burn process. CComPtr and CComQIPtr are templated based classes that are very useful because the developer is freed from interface pointer release nightmare. The proper way to declare variables that use those two classes would be:

CComPtr<IBURNCALLBACKS> pBurnCallbacks;
CComQIPtr<IBURNCALLBACKS> pBurnCallbacks2;

For the difference between the two classes, consult MSDN help. Generally, the former is just a plain smart pointer while the latter does a QueryInterface before assignment.


#3

hi alexp,

thanks for the quick answer, but it doesn’t help me very much.

the implementation of the IBurnCallback Interface is my problem.

here is my code:

in .h file

//
// IBurnCallbacks implementation
// 
STDMETHOD (OnDoneBurn) (NEROAPI_BURN_ERROR burnError);
STDMETHOD (Progress) (DWORD dwProgressInPercent, BOOL* pbRetVal);
STDMETHOD (SubtaskProgress) (DWORD dwProgressInPercent, BOOL* pbRetVal);
STDMETHOD (AddLogLine) (NERO_TEXT_TYPE type, BSTR bstrLogLine);
STDMETHOD (SetPhase) (BSTR bstrPhase);
STDMETHOD (SetMajorPhase) (NERO_MAJOR_PHASE majorPhase);
STDMETHOD (Aborted) (BOOL* pbRetVal);
STDMETHOD (DisableAbort) (BOOL bAbortEnabled);

and in the .cpp file


CComQIPtr<IBurnCallbacks> pBurnCallbacks;
.
.
.
pBurnProgressDlg.p->Burn2 (m_pDeviceInfo, NERO_ISO_AUDIO_CD, &m_WriteCD, 
			   NBF_DETECT_NON_EMPTY_CDRW|NBF_WRITE|NBF_DAO|NBF_SPEED_IN_KBS, 
			   m_dwWriteSpeedInKBs, pBurnCallbacks);


STDMETHODIMP CBurnDialog::OnDoneBurn (NEROAPI_BURN_ERROR burnError)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::Progress (DWORD dwProgressInPercent, BOOL* pbRetVal)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::SubtaskProgress (DWORD dwProgressInPercent, BOOL* pbRetVal)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::AddLogLine (NERO_TEXT_TYPE type, BSTR bstrLogLine)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::SetPhase (BSTR bstrPhase)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::SetMajorPhase (NERO_MAJOR_PHASE majorPhase)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::Aborted (BOOL* pbRetVal)
{
	return S_OK;
}

STDMETHODIMP CBurnDialog::DisableAbort (BOOL bAbortEnabled)
{
	return S_OK;
}

the burnprocess and its dialog work great, but none of the callbackfunction is called. is there anything missing to make the function to be called??


#4

I first thought that the portion CComQIPtr<IBURNCALLBACKS> pBurnCallbacks; was an error on your part but it seems that the forum skips over everything that looks like a tag. Your code probably reads CComQIPtr<<IBURNCALLBACKS>pBurnCallbacks> pBurnCallbacks; but it was filtered.

Anyway, it is still incorrect. Unless you have skipped over some relevant code portions, the quoted code shows the problem clearly. You declare a smart pointer (which is initialized to NULL by default) and later on you pass it to Burn2 function. Nothing happens in between. Basically, you pass NULL to the burn function in place of a valid IBurnCallbacks interface pointer. That is why no events are fired.

You should do the following instead: CComQIPtr<IBURNCALLBACKS> pBurnCallbacks (your_objects_that_implements_IBurnCallbacks); This will do a QueryInterface on the thing in brackets asking for a IBurnCallbacks. Now, if your CBurnDialog class implements IBurnCallbacks (as the code suggests), a CBurnDialog pointer should probably be passed as a CComQIPtr constructor’s parameter.

I hope it made things a bit clearer.


#5

hi alexp,

it work’s, thanks a lot!!! :bow: :bow:

now everything’s running very well. you did really a great job.

bye, puppy