|
-
November 19th, 2007, 05:08 AM
#4
Re: Assertion failure in load/setbitmap()
Thanks for your reply
Calling DeleteObject on my bitmap seems to work out that problem. Having looked at it a little closer, it seems to me that the problem might be that the window handler for the CStatic == 0?
I thought this would be taken care of by the
DDX_Control(pDX, IDC_PORTCANNONBMP, m_oPortCannonCtrl);
DDX_Control(pDX, IDC_STBDCANNONBMP, m_oStbdCannonCtrl);
(The IDC's being the ID of my picture boxes.)
Or do I need to do something more to draw the static in my dialog window?
If so, how do I set the handler correct?
Here's an exact copy of the code:
Code:
HBRUSH CCntrPartDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CGuiBase::OnCtlColor(pDC, pWnd, nCtlColor);
// Set brush to desired background color
CPalette * pPalette = (CPalette*)GetPalette();
int iLightMode = m_iCurrentLightMode;
GetLightMode(&iLightMode, -1);
if(iLightMode != m_iCurrentLightMode || m_iCurrentLightMode < 0)
{
try
{
if(iLightMode==BRIGHT_DAYLIGHT_DISP||iLightMode==WHITE_DAY_LIGHT_DISP) //0
{
m_iCurrentLightMode = iLightMode;
m_oPortCannonBmp.DeleteObject();
m_oStbdCannonBmp.DeleteObject();
m_oPortCannonBmp.LoadBitmap(IDB_PORTCANNONDAY);
m_oStbdCannonBmp.LoadBitmap(IDB_STBDCANNONDAY);
}
else
{
m_iCurrentLightMode = iLightMode;
m_oPortCannonBmp.DeleteObject();
m_oStbdCannonBmp.DeleteObject();
m_oPortCannonBmp.LoadBitmap(IDB_PORTCANNONNIGHT);
m_oStbdCannonBmp.LoadBitmap(IDB_STBDCANNONNIGHT);
}
m_oPortCannonCtrl.SetBitmap(m_oPortCannonBmp);
// m_oPortCannonCtrl.Invalidate();
m_oStbdCannonCtrl.Attach((HWND)&pWnd);//
m_oStbdCannonCtrl.SetBitmap(m_oStbdCannonBmp);
}
catch(...)
{
m_oStbdCannonBmp.Detach();
}
}
...
}
DEbug info from the variables:
+ m_oStbdCannonCtrl {CStatic hWnd=0x0013a884 {unused=0 }} CStatic
+ m_oPortCannonCtrl {CStatic hWnd=0x019a06f8 {unused=0 }} CStatic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|