IViewObject::Draw

G

Guest

I am using Flash ocx to play the .swf file in a windowless container.
Now I use IViewObject::Draw to render the contents on the HDC provided by me.
I create a compatible DC passing NULL parameter.
CreateCompatibleDC(NULL)

Then I create a 32 bit DIB section of certain width height, and select this
DIB into the above created DC once.

BITMAPINFO BitmapInfo;
ZeroMemory(&BitmapInfo,sizeof(BITMAPINFO));
BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
BitmapInfo.bmiHeader.biHeight = -m_lHeight;
BitmapInfo.bmiHeader.biWidth = m_lWidth;
BitmapInfo.bmiHeader.biPlanes = 1;
BitmapInfo.bmiHeader.biBitCount = 32;
BitmapInfo.bmiHeader.biClrUsed = 0;
m_hCompatibleBmp = CreateDIBSection(m_hCompatibleDC,
&BitmapInfo,
DIB_RGB_COLORS,
(void**)&m_pBitmapBits,
NULL,
0);

// Selecting the bitmap in the created device context
m_hOldBitmap = (HBITMAP)SelectObject(m_hCompatibleDC, m_hCompatibleBmp);


Then at regular intervals I call
IViewObject::Draw as...............

bContinue = TRUE;
hr = m_spViewObj->Draw(DVASPECT_CONTENT,
0,
NULL,
NULL,
NULL,
m_hCompatibleDC,
NULL,
NULL,
NULL,
bContinue));


Now the problem is that Draw call gives a access violation(caught in try
catch block) sometime after many calls, but the returned HRESULT is S_OK

The access violation as printed in output windows is ..............
0xC0000005: Access violation writing location 0xfeeefefe.


Once it gives access violation then it doesnt draw anything on the DC
supplied on subsequent calls, though it returns S_OK in each case.
I am really stuck up with this problem.

Is there a problem with the bitmap i am selecting in the Device context and
some other problem?

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top