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. Simple CToolTipCtrl trouble.

Simple CToolTipCtrl trouble.

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 Posters 2 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
    Nikz2
    wrote on last edited by
    #1

    Hi. Well.. I need to add some tooltips to my main window (CDialog). So... I do this in OnInit

    bool test21=TTC.Create(this); //creating tooltipwindow
    theApp.tooltip=&(TTC);
    m\_but.MoveWindow(0,0,500,500);
    bool test11=theApp.tooltip->AddTool(m\_but,"Cool?");
    TTC.Activate(TRUE);
    

    and

    BOOL MainDial::PreTranslateMessage(MSG* pMsg)
    {
    if (NULL != theApp.tooltip)
    theApp.tooltip->RelayEvent(pMsg);
    return CDialog::PreTranslateMessage(pMsg);
    }

    Appears a great button, but hint doesn't. Why? Any idea? Smthng that i'am missing? Huh?

    C 1 Reply Last reply
    0
    • N Nikz2

      Hi. Well.. I need to add some tooltips to my main window (CDialog). So... I do this in OnInit

      bool test21=TTC.Create(this); //creating tooltipwindow
      theApp.tooltip=&(TTC);
      m\_but.MoveWindow(0,0,500,500);
      bool test11=theApp.tooltip->AddTool(m\_but,"Cool?");
      TTC.Activate(TRUE);
      

      and

      BOOL MainDial::PreTranslateMessage(MSG* pMsg)
      {
      if (NULL != theApp.tooltip)
      theApp.tooltip->RelayEvent(pMsg);
      return CDialog::PreTranslateMessage(pMsg);
      }

      Appears a great button, but hint doesn't. Why? Any idea? Smthng that i'am missing? Huh?

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Could it be that in your OnInitDialog the TTC variable, which is i assume a CToolTipCtrl a local variable? If so then when your OnInitDialog is done and returns, TTC will be deleted and its destructor also destroys the tooltip. Of course that you don't get a crash in PreTranslateMessage suggests this is not the case but it might happen. Try making your TTC a member of the dialog class if it is not and use that instance instead of storing a pointer at it.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

      N 1 Reply Last reply
      0
      • C Code o mat

        Could it be that in your OnInitDialog the TTC variable, which is i assume a CToolTipCtrl a local variable? If so then when your OnInitDialog is done and returns, TTC will be deleted and its destructor also destroys the tooltip. Of course that you don't get a crash in PreTranslateMessage suggests this is not the case but it might happen. Try making your TTC a member of the dialog class if it is not and use that instance instead of storing a pointer at it.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

        N Offline
        N Offline
        Nikz2
        wrote on last edited by
        #3

        Well.. My CToolTipCtrl is member of MainDial of course. And by the way i already made it work with this button, but now i have another trouble. I create lots of dynamic buttons, inside of MPictureBox.Create i write:

        	BOOL result = CButton::Create(lpszCaption,dwStyle,rect,pParentWnd,nID);
        	this->SetParent(pParentWnd);
        	theApp.tooltip->AddTool(this,"HM?!");
        

        but once again it doesn't help. Hint doesn't appear. Any idea?

        C 1 Reply Last reply
        0
        • N Nikz2

          Well.. My CToolTipCtrl is member of MainDial of course. And by the way i already made it work with this button, but now i have another trouble. I create lots of dynamic buttons, inside of MPictureBox.Create i write:

          	BOOL result = CButton::Create(lpszCaption,dwStyle,rect,pParentWnd,nID);
          	this->SetParent(pParentWnd);
          	theApp.tooltip->AddTool(this,"HM?!");
          

          but once again it doesn't help. Hint doesn't appear. Any idea?

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          You probably need to relay messages received by your picture box also to the tooltip control not only ones targeted at your dialog box. Aside of that, no idea. Just out of curiosity, what was your first problem?

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

          N 1 Reply Last reply
          0
          • C Code o mat

            You probably need to relay messages received by your picture box also to the tooltip control not only ones targeted at your dialog box. Aside of that, no idea. Just out of curiosity, what was your first problem?

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

            N Offline
            N Offline
            Nikz2
            wrote on last edited by
            #5

            My original problem was to make some sort of game. Jackal. It's a board game invented 30-40 years ago at MGU (principal university of Moscow). For now i made it, but it's possible to play it only for humans against humans on the same cpu (hot seat mode). (Later i plan to make net support and cpu gamers). If you want to see what i have done for now drop.io/shchepin/ release.rar (requires redistributable package for vs2008 sp1). P.S. I intented with

            BOOL MPictureBox::PreTranslateMessage(MSG* pMsg)
            {
            if (NULL != theApp.tooltip)
            theApp.tooltip->RelayEvent(pMsg);
            return CButton::PreTranslateMessage(pMsg);
            }

            Didn't helped... =(

            C 1 Reply Last reply
            0
            • N Nikz2

              My original problem was to make some sort of game. Jackal. It's a board game invented 30-40 years ago at MGU (principal university of Moscow). For now i made it, but it's possible to play it only for humans against humans on the same cpu (hot seat mode). (Later i plan to make net support and cpu gamers). If you want to see what i have done for now drop.io/shchepin/ release.rar (requires redistributable package for vs2008 sp1). P.S. I intented with

              BOOL MPictureBox::PreTranslateMessage(MSG* pMsg)
              {
              if (NULL != theApp.tooltip)
              theApp.tooltip->RelayEvent(pMsg);
              return CButton::PreTranslateMessage(pMsg);
              }

              Didn't helped... =(

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              What kind of a control is that picturebox?

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

              N 1 Reply Last reply
              0
              • C Code o mat

                What kind of a control is that picturebox?

                > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

                N Offline
                N Offline
                Nikz2
                wrote on last edited by
                #7

                Just like i said before, it's a CButton child.

                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