Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Deskband (XP) Problem..

Deskband (XP) Problem..

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocomgraphicsperformancehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitin3
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups