Deskband (XP) Problem..
-
Hi, I'm trying to create a deskband (windows xp). The class which implement IDeskBand is CBand. I've created some brush in the constructor of this class. And destroyed in destructor. right click taskbar->toolbars-> select MyBand, now my deskband is visible. then right click taskbar->toolbars->MyBand, now my deskband is gone. But the gdi items are still in memory ? It seems the destructor is not called. If repeat show, hide deskband, the gdi object count increases with every time. I've created it as specified in the following url. http://msdn.microsoft.com/en-us/library/cc144099(v=vs.85).aspx
CBand::CBand()
{
//ALWAYS SHOWS
MessageBox(0, "Construct", 0,0) ;
m_lRef = 1 ;
//create obejcts...
}
CBand::~CBand()
{
//NEVER SHOWN
MessageBox(0, "Destruct", 0,0) ;
//delete objects
}DWORD __stdcall CBand::AddRef()
{
return InterlockedIncrement(&m_lRef) ;
}
DWORD __stdcall CBand::Release()
{
if( InterlockedDecrement(&m_lRef) == 0 )
{
delete this ;
}
return m_lRef ;
}
HRESULT __stdcall CBand::QueryInterface( REFIID riid , void** ppvObj )
{
*ppvObj = NULL;if(IsEqualIID(riid, IID\_IUnknown)) { \*ppvObj = this; } . . . . if(\*ppvObj) { (\*(LPUNKNOWN\*)ppvObj)->AddRef(); return S\_OK; } return E\_NOINTERFACE;
}
HRESULT __stdcall ShellFactory::CreateInstance(IUnknown* pUnknownOuter , const IID& iid , void** ppv )
{
if( pUnknownOuter != NULL )
{
return ResultFromScode( CLASS_E_NOAGGREGATION ) ;
}if( IsEqualCLSID(m\_clsid , CLSID\_MyBand)) { CBand \* pObj = new CBand() ; if( pObj == NULL ) { return E\_OUTOFMEMORY; } HRESULT hRes = pObj->QueryInterface( iid , ppv ) ; if(FAILED(hRes) ) { pObj->Release() ; } return hRes; } return S\_FALSE ;
}
Thanks & Regards