A MDI app, CScrollView, in OnDraw works fine in debug, nothing displayed in release! WHY???
Hi,
I have this application (MDI)... In it are views (CScrollView) that are
displayed using overloading of OnDraw.
In OnDraw I display a bunch of thumbnails contained in a STL set
(ie. set<string>, where string is filename)...
Each thumbnail get a RECT and tools are activated whenever
user click inside a rect...
In DEBUG, I see everything displayed and the tools match the picture
seclected...
BUT in release NOTHING is displayed! Yet, the RECT is set because
I can select an image (tools adjusted)! It's just that it doesn't
get displayed!!!!!!! Any idea why? And how to fit it?
What could be missing in release that is there in debug???
here is the code of the DrawBitmap function used to display the
image. Any hints as to what is going wrong will be appreciated ;-)
void CMyView::DrawBitmap( CDC *pDC, HBITMAP hBitmap, HPALETTE hPal, int xDest, int yDest, int width, int height, bool selected )
{
// Get logical coordinates
BITMAP bm;
::GetObject( hBitmap, sizeof( bm ), &bm );
CPoint size( bm.bmWidth, bm.bmHeight );
pDC->DPtoLP(&size);
CPoint org(0,0);
pDC->DPtoLP(&org);
// Create a memory DC compatible with the destination DC
CDC memDC;
memDC.CreateCompatibleDC( pDC );
memDC.SetMapMode( pDC->GetMapMode() );
Its the HBITMAP that does not seems to be ok in
release! Here it is:
void CMyView::DrawBitmap( CDC *pDC, HBITMAP hBitmap, HPALETTE hPal, int xDest, int yDest, int width,
int height, bool selected )
{
// Get logical coordinates
BITMAP bm;
::GetObject( hBitmap, sizeof( bm ), &bm );
the bm.bmWidth, bm.bmHeight are 1 in release and
are correct in debug!
if (dib != NULL)
{
(*bitmap)= dib->MakeBitmap(pDC);
....
Now SECJpeg is a cless from ObjectiveToolkit (stingray's)
and this call to dib->MakeBitmap(pDC); works only
in debug! In release it does not! WHY?????????????
Further, if I put this code:
SECDib pp;
pp.CreateFromBitmap(pDC, (*bitmap));
pp.SaveImage("toto.bmp");
the file "toto.bmp" is ok in debug but of size 1k in release!
So this is the culprit :SECImage::MakeBitmap()
But why does it fail in release and not in debug????
Anyone familiar with stingray?
I used it (objective toolkit 6.02) because their classes
had a nice wrapper to jpg and bmp but it does not
work :(
Do you have any idea why the function fails in release?
Before the call to GetBitmapAndPalette(), is there any way to verify that pImage is valid? Maybe it's been corrupted before the call.
Also, is there any way to check that pImage->GetThumbnail() is working correctly?
When I come across a bug like this, I usually try commenting out code (or replacing it with simpler code) until the problem goes away. That helps narrow down the bug some more.
Another approach is to generate an app (using AppWizard) and gradually introduce your problem code until the bug appears.
0
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
Hmmm...when a DC is created it has a 1x1 monochrome bitmap in it.
If this is the case when it's passed to OnDraw() (and I'm not 100% sure about this) then the call to CreateCompatibleBitmap() in SECImage::MakeBitmap() will create the same thing....
Try using the DC from GetDC() & passing it to MakeBitmap(). Call ReleaseDC() afterwards.
I did put in your code and it changed nothing...
But i decided to clean and rebuild all my app
and now I get finally an error in (you guessed it!)
LoadThumbnail....
Seems devstudio was mixed up and did not compiled
the project properly (it's in a dll)...
I think a VERIFY insterd of an ASSERT will ensure
the function is properly called both in debug and in release
and now that I have an error that makes sense I can go on
on my own ;-)