- ::SelectObject(hdcMem, GetHbitmapOf(bmp));
- if (bmp.GetPalette() && (::GetDeviceCaps(cdc,BITSPIXEL) <= 8)) {
- oldPal = ::SelectPalette( hdcMem, (HPALETTE)bmp.GetPalette()->GetHPALETTE(), FALSE);
+ HGDIOBJ hOldBitmap = ::SelectObject(hdcMem, GetHbitmapOf(bmp));
+#if wxUSE_PALETTE
+ wxPalette *pal = bmp.GetPalette();
+ if ( pal && ::GetDeviceCaps(cdc,BITSPIXEL) <= 8 )
+ {
+ oldPal = ::SelectPalette(hdcMem, GetHpaletteOf(pal), FALSE);