CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Destroy toolbar problem

    Hi !

    I'm creating a toolbar i.e. like this:

    HTML Code:
    bar=new CToolBar();
    bar->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0, 0, 0, 0),23423);
    FloatControlBar(bar,CPoint (400,400));

    Next I delete this toolbar i.e. like this:

    HTML Code:
    delete bar;
    All look ok, without one point: GDI objects are still allocate in memory (I can find it in monitor). In create are allocate 8 GDI objects, in delete remove only 2. So 6 are still allocate. In my application I create/delete toolbars often, and this generate a problem.

    Do you know how safty remove a toolbar from memory with deallocate this gdi objects ?

    Thnx in advance

    Olek

  2. #2
    Join Date
    Jul 2005
    Posts
    767

    Re: Destroy toolbar problem

    bar is a C++ object associated with a windows control. Just as you created the control using CreateEx use DestroyWindow before deleting the object.

  3. #3
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Re: Destroy toolbar problem

    Unfortuality: This is first what I try. Result is this same: GDI object are not free....

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Destroy toolbar problem

    Quote Originally Posted by olekba
    Unfortuality: This is first what I try. Result is this same: GDI object are not free....
    Then Would you be so kind to post a little more code to see what and how you created/loaded/destroyed the toolbar and in what class you are using it?

  5. #5
    Join Date
    Sep 2001
    Location
    Rotmanka, Poland
    Posts
    88

    Re: Destroy toolbar problem

    In reality, I extract this, what generate a problem, to another project. And this is in a first post. Here you can find, that this is normal CToolBar.


    I try several thinks for destroy this GDI objects, like:

    bar->DestroyWindow();
    delete bar;

    or

    //ShowControlBar(bar,FALSE,FALSE);
    //bar->EnsureParentFrame()->DestroyWindow();
    // bar->SendMessage(WM_NCDESTROY);
    //DestroyDockBars();
    //CFrameWnd* pFrameWnd = bar->EnsureParentFrame();
    //pFrameWnd->DestroyWindow();


    But I still see, that nothink changing with a allocate a GDI objects. In my real application create/destroy toolbars is often. In one costumer computer is a problem, that if are to many allocate GDI objects - application crash.


    Any ideas ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured