Microsoft Visual C & C++: still with the tooltips *sigh*

  • kallareka / 202 / Tues, 09 Feb 2010 18:57:00 GMT / Comments (2)
  • I have a dialog in which i create buttons dynamically, i have derived my own class called CBokningsButton from CButton... here's the problem, i get an assertion error when i try to do: m_tooltip.AddTool(GetDlgItem(9001 ,"hey"));
    the assertion error is: ASSERT(::IsWindow(m_hWnd));

    the wierd part (or the part I find wierd) is that i can do this if i double create the buttons. it hard for me to explain exactly how i mean but ill try:

    When i run the prog it creates some buttons then if the user change some stuff it deletes the buttons and create new ones. each button represents a different time in a day, depending on which day the users select the buttons can have a different layout depending in the information i get from a mysql database.
    So before i create buttons i delete the old ones like this:

    CBokningsButton* ptrButton;
    for(int t=0;t<200;t++)
    {
    if( (ptrButton = (CBokningsButton*)GetDlgItem(9001+t)) != NULL)
    {
    // button exists
    ptrButton->DestroyWindow();
    }
    }

    now i know this i like the worst solution ever to delete buttons but never mind that now, the thing is that if i replace the DestroyWindow() line with my AddTool line i get the tooltips to work the second time i create the buttons (rember that now the old ones hasnt been deleted so the new are just printed on top of the old ones).
    If i try to do the AddTool any place else in the program i get the assertion error...

    i thought it to be most logical to do AddTool at the same time i create the button but that gives me the same error

    does anyone know what im talking about and if so can you help me?

    thanx

    /Eric
  • Keywords:

    still, tooltips, sigh, microsoft, visual c++, vc

  • http://www.edevs.com/visual-c-c++/73089/«« Last Thread - Next Thread »»
    1. Hi Eric,

      Take a look in the attached little sample project.
      I hope will be helpful.

      Regards,

      ovidiucucu | Sun, 11 Nov 2007 03:01:34 GMT |

    2. thank you very much! this was very helpfull im sorry i never saw your reply until now...

      again, thanx

      /Eric

      kallareka | Sun, 11 Nov 2007 03:02:37 GMT |