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. Delete Button problem

Delete Button problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++debugging
3 Posts 2 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.
  • R Offline
    R Offline
    Ruca
    wrote on last edited by
    #1

    Hi! I'm working on a CFormView derived class, and i had the need of creating a ownerdraw button. In the .h file i wrote : CMyButton botao; ...and then, in the .cpp i created like this: ~ botao.Create("Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_OWNERDRAW, CRect(10, m_iLastY+70, 150, m_iLastY+100), this, BTN); The first time i call that form, no problem it works, but the next time i call it i get an debug assertation error! In Debug i can see that the hwnd of botao is 0x00000000 and the next time i stop in the line in which i'm creating it i have a value there. How can i make botao's hwnd equal to 0x00000000 again? Thank you Rui

    R 1 Reply Last reply
    0
    • R Ruca

      Hi! I'm working on a CFormView derived class, and i had the need of creating a ownerdraw button. In the .h file i wrote : CMyButton botao; ...and then, in the .cpp i created like this: ~ botao.Create("Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_OWNERDRAW, CRect(10, m_iLastY+70, 150, m_iLastY+100), this, BTN); The first time i call that form, no problem it works, but the next time i call it i get an debug assertation error! In Debug i can see that the hwnd of botao is 0x00000000 and the next time i stop in the line in which i'm creating it i have a value there. How can i make botao's hwnd equal to 0x00000000 again? Thank you Rui

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Ruca wrote: In Debug i can see that the hwnd of botao is 0x00000000 and the next time i stop in the line in which i'm creating it i have a value there. Sure, because once you successfully create your button, it is assigned a handle, namely the hwnd. Ruca wrote: How can i make botao's hwnd equal to 0x00000000 again? You'll have to destroy your button before recreating it. For that,it may be helpful to run botao.Detach() in such a way :

      if (botao.m_hwnd!=NULL)
      botao.Detach();
      else
      botao.Create("Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_OWNERDRAW, CRect(10, m_iLastY+70, 150, m_iLastY+100), this, BTN);

      Well, that's what i would try. BUT I'm not very qualified, so it can be that this is all wrong.:| ~RaGE();

      R 1 Reply Last reply
      0
      • R Rage

        Ruca wrote: In Debug i can see that the hwnd of botao is 0x00000000 and the next time i stop in the line in which i'm creating it i have a value there. Sure, because once you successfully create your button, it is assigned a handle, namely the hwnd. Ruca wrote: How can i make botao's hwnd equal to 0x00000000 again? You'll have to destroy your button before recreating it. For that,it may be helpful to run botao.Detach() in such a way :

        if (botao.m_hwnd!=NULL)
        botao.Detach();
        else
        botao.Create("Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_OWNERDRAW, CRect(10, m_iLastY+70, 150, m_iLastY+100), this, BTN);

        Well, that's what i would try. BUT I'm not very qualified, so it can be that this is all wrong.:| ~RaGE();

        R Offline
        R Offline
        Ruca
        wrote on last edited by
        #3

        Thank you very much Rage, i tried it, but even with .Deatch() (i also tryed botao.m_hwnd==NULL) , i get an error when executing, and now i'sure the m_hWnd is 0x000000, is there any other variable i should worry about?. Thank you Rui

        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