Delete Button problem
-
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
-
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
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 runbotao.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();
-
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 runbotao.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();