From: Mark Foley on 20 Feb 2007 16:10 Can comeone please explain to me why this seems to not work as advertised? I have seen countless examples which go to great lengths to implement what I want to do and which seems as if it should be quite simple. I have multiple IPictEditor controls which are a simple LED box on a dialog. I have created and added a CToolTipCtrl for each one. All of this works perfectly - the tooltip pops up just like I want it to. Periodically I update the tooltip text using UpdateTipText(). No problem there. What I would like to be able to do is update the text when the user moves the cursor over the tooltip area. The documentation for the CToolTipCtrl class seems to indicate that this should be as simple as: 1. Override OnToolHitTest() ie. INT_PTR CMon::OnToolHitTest(CPoint point, TOOLINFO* pTI) const INT_PTR CMon::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { BOOL res; CToolInfo m_ToolInfo; TRACE("\n Point %d, %d Hit",point.x,point.y); for (int i=0; i<IBS_MAXIMUM_POL_COUNT; i++) { // Get the ToolInfo about this Tool if (m_POLErrorInfo[i].GetToolInfo(m_ToolInfo, GetDlgItem(IDC_RUN_0+i))) { if (m_POLErrorInfo[i].HitTest(GetDlgItem(IDC_RUN_0+i), point, (LPTOOLINFO)&m_ToolInfo)) { TRACE("\n Tooltip for POL %d is hit",i); // I should be able to call UpdateTipText() to update my text... } } } return Dialog_Brush_Base::OnToolHitTest(point, pTI); } The HitTest always returns true, regardless of where the cursor is. GetToolInfo() correctly returns info about my tooltip.
From: AliR (VC++ MVP) on 20 Feb 2007 16:37 Did you specify a problem in this post? I read the entire thing but did see a question! Is the question why m_POLErrorInfo[i].HitTest() return TRUE all the time? That all depends on what your AddTool method looks like? Why do you have an array of CToolTipCtrls? You should have one pre dialog and add multiple tools (control) to it using AddTool. After you do that CToolTipCtrl::HitTest will return the control id of the control under the mouse. As far as your OnToolHitTest goes you should return pTI->uId if you want to change the tooltip or -1 if you don't. (The doc is wrong on that you have to return 1). AliR. "Mark Foley" <foleym(a)meftechno.com> wrote in message news:45db63ac$0$1372$4c368faf(a)roadrunner.com... > Can comeone please explain to me why this seems to not work as advertised? > I have seen countless examples which go to great lengths to implement > what I want to do and which seems as if it should be quite simple. > > I have multiple IPictEditor controls which are a simple LED box > on a dialog. > > I have created and added a CToolTipCtrl for each one. All of this works > perfectly - the tooltip pops up just like I want it to. > > Periodically I update the tooltip text using UpdateTipText(). No > problem there. > > What I would like to be able to do is update the text when the user moves > the cursor over the tooltip area. > > The documentation for the CToolTipCtrl class seems to indicate that this > should be as simple as: > > 1. Override OnToolHitTest() ie. INT_PTR CMon::OnToolHitTest(CPoint point, > TOOLINFO* pTI) const > > > INT_PTR CMon::OnToolHitTest(CPoint point, TOOLINFO* pTI) const > { > > BOOL res; > CToolInfo m_ToolInfo; > > TRACE("\n Point %d, %d Hit",point.x,point.y); > > for (int i=0; i<IBS_MAXIMUM_POL_COUNT; i++) > { > // Get the ToolInfo about this Tool > if (m_POLErrorInfo[i].GetToolInfo(m_ToolInfo, GetDlgItem(IDC_RUN_0+i))) > { > if (m_POLErrorInfo[i].HitTest(GetDlgItem(IDC_RUN_0+i), point, > (LPTOOLINFO)&m_ToolInfo)) > { > TRACE("\n Tooltip for POL %d is hit",i); > // I should be able to call UpdateTipText() to update my text... > } > > } > > } > return Dialog_Brush_Base::OnToolHitTest(point, pTI); > } > > > > The HitTest always returns true, regardless of where the cursor is. > GetToolInfo() correctly returns info about my tooltip. >
From: Mark Foley on 20 Feb 2007 17:27 I have an array of 32 tooltip controls because I have 32 LEDs. The tooltip for a given LED is not always enabled, hence Activate() must apply only to a given control/tooltip. The question is how can I update the text when the cursor is placed over the control such that the tooltip pops up current information? Thanks! "AliR (VC++ MVP)" <AliR(a)online.nospam> wrote in message news:HSJCh.15994$O02.15608(a)newssvr11.news.prodigy.net... > Did you specify a problem in this post? I read the entire thing but did > see a question! > Is the question why m_POLErrorInfo[i].HitTest() return TRUE all the time? > That all depends on what your AddTool method looks like? > > Why do you have an array of CToolTipCtrls? You should have one pre dialog > and add multiple tools (control) to it using AddTool. After you do that > CToolTipCtrl::HitTest will return the control id of the control under the > mouse. > > As far as your OnToolHitTest goes you should return pTI->uId if you want > to change the tooltip or -1 if you don't. (The doc is wrong on that you > have to return 1). > > > AliR. > > "Mark Foley" <foleym(a)meftechno.com> wrote in message > news:45db63ac$0$1372$4c368faf(a)roadrunner.com... >> Can comeone please explain to me why this seems to not work as >> advertised? >> I have seen countless examples which go to great lengths to implement >> what I want to do and which seems as if it should be quite simple. >> >> I have multiple IPictEditor controls which are a simple LED box >> on a dialog. >> >> I have created and added a CToolTipCtrl for each one. All of this works >> perfectly - the tooltip pops up just like I want it to. >> >> Periodically I update the tooltip text using UpdateTipText(). No >> problem there. >> >> What I would like to be able to do is update the text when the user moves >> the cursor over the tooltip area. >> >> The documentation for the CToolTipCtrl class seems to indicate that this >> should be as simple as: >> >> 1. Override OnToolHitTest() ie. INT_PTR CMon::OnToolHitTest(CPoint point, >> TOOLINFO* pTI) const >> >> >> INT_PTR CMon::OnToolHitTest(CPoint point, TOOLINFO* pTI) const >> { >> >> BOOL res; >> CToolInfo m_ToolInfo; >> >> TRACE("\n Point %d, %d Hit",point.x,point.y); >> >> for (int i=0; i<IBS_MAXIMUM_POL_COUNT; i++) >> { >> // Get the ToolInfo about this Tool >> if (m_POLErrorInfo[i].GetToolInfo(m_ToolInfo, GetDlgItem(IDC_RUN_0+i))) >> { >> if (m_POLErrorInfo[i].HitTest(GetDlgItem(IDC_RUN_0+i), point, >> (LPTOOLINFO)&m_ToolInfo)) >> { >> TRACE("\n Tooltip for POL %d is hit",i); >> // I should be able to call UpdateTipText() to update my text... >> } >> >> } >> >> } >> return Dialog_Brush_Base::OnToolHitTest(point, pTI); >> } >> >> >> >> The HitTest always returns true, regardless of where the cursor is. >> GetToolInfo() correctly returns info about my tooltip. >> > >
From: AliR (VC++ MVP) on 20 Feb 2007 18:14 If I were you I would use the TTN_NEEDTEXT message. With that said you will need to get rid of all the CToolTipCtrls that you currently create. Here all you have to do is call EnableToolTips(TRUE) in your dialog OnInitDialog().. Then you catch the TTN_NEEDTEXT notify message like this BEGIN_MESSAGE_MAP(CMyDialog, CDialog) ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify) END_MESSAGE_MAP() BOOL CMyDialog::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) { TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; UINT nID =pNMHDR->idFrom; if (pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); pTTT->hinst = AfxGetResourceHandle(); switch (nID) { case IDOK : pTTT->lpszText = "OK Button"; return TRUE; case IDCANCEL : pTTT->lpszText = "Cancel Button"; return TRUE; default: return FALSE; } } return FALSE; } AliR. "Mark Foley" <foleym(a)meftechno.com> wrote in message news:45db75de$0$8969$4c368faf(a)roadrunner.com... >I have an array of 32 tooltip controls because I have 32 LEDs. The tooltip >for a given LED is not > always enabled, hence Activate() must apply only to a given > control/tooltip. > > The question is how can I update the text when the cursor is placed over > the control such that the > tooltip pops up current information? > > Thanks! > > "AliR (VC++ MVP)" <AliR(a)online.nospam> wrote in message > news:HSJCh.15994$O02.15608(a)newssvr11.news.prodigy.net... >> Did you specify a problem in this post? I read the entire thing but did >> see a question! >> Is the question why m_POLErrorInfo[i].HitTest() return TRUE all the time? >> That all depends on what your AddTool method looks like? >> >> Why do you have an array of CToolTipCtrls? You should have one pre >> dialog and add multiple tools (control) to it using AddTool. After you >> do that CToolTipCtrl::HitTest will return the control id of the control >> under the mouse. >> >> As far as your OnToolHitTest goes you should return pTI->uId if you want >> to change the tooltip or -1 if you don't. (The doc is wrong on that you >> have to return 1). >> >> >> AliR. >> >> "Mark Foley" <foleym(a)meftechno.com> wrote in message >> news:45db63ac$0$1372$4c368faf(a)roadrunner.com... >>> Can comeone please explain to me why this seems to not work as >>> advertised? >>> I have seen countless examples which go to great lengths to implement >>> what I want to do and which seems as if it should be quite simple. >>> >>> I have multiple IPictEditor controls which are a simple LED box >>> on a dialog. >>> >>> I have created and added a CToolTipCtrl for each one. All of this works >>> perfectly - the tooltip pops up just like I want it to. >>> >>> Periodically I update the tooltip text using UpdateTipText(). No >>> problem there. >>> >>> What I would like to be able to do is update the text when the user >>> moves >>> the cursor over the tooltip area. >>> >>> The documentation for the CToolTipCtrl class seems to indicate that this >>> should be as simple as: >>> >>> 1. Override OnToolHitTest() ie. INT_PTR CMon::OnToolHitTest(CPoint >>> point, TOOLINFO* pTI) const >>> >>> >>> INT_PTR CMon::OnToolHitTest(CPoint point, TOOLINFO* pTI) const >>> { >>> >>> BOOL res; >>> CToolInfo m_ToolInfo; >>> >>> TRACE("\n Point %d, %d Hit",point.x,point.y); >>> >>> for (int i=0; i<IBS_MAXIMUM_POL_COUNT; i++) >>> { >>> // Get the ToolInfo about this Tool >>> if (m_POLErrorInfo[i].GetToolInfo(m_ToolInfo, GetDlgItem(IDC_RUN_0+i))) >>> { >>> if (m_POLErrorInfo[i].HitTest(GetDlgItem(IDC_RUN_0+i), point, >>> (LPTOOLINFO)&m_ToolInfo)) >>> { >>> TRACE("\n Tooltip for POL %d is hit",i); >>> // I should be able to call UpdateTipText() to update my text... >>> } >>> >>> } >>> >>> } >>> return Dialog_Brush_Base::OnToolHitTest(point, pTI); >>> } >>> >>> >>> >>> The HitTest always returns true, regardless of where the cursor is. >>> GetToolInfo() correctly returns info about my tooltip. >>> >> >> > >
From: Mark Foley on 21 Feb 2007 13:00 This will work, but only for Controls like a button. I am using images via IPictEditor. OnToolTipNotify() doesn't seem to get called for Static type 'controls'. I have seen several somewhat cumbersome solutions ranging from Subclassing to a bunch of code added to PreTranslateMessage(). Neither seems very attractive. Is there a simpler solution? Thank you! "AliR (VC++ MVP)" <AliR(a)online.nospam> wrote in message news:FhLCh.30947$yC5.30435(a)newssvr27.news.prodigy.net... > If I were you I would use the TTN_NEEDTEXT message. With that said you > will need to get rid of all the CToolTipCtrls that you currently create. > Here all you have to do is call EnableToolTips(TRUE) in your dialog > OnInitDialog().. Then you catch the TTN_NEEDTEXT notify message like this > > BEGIN_MESSAGE_MAP(CMyDialog, CDialog) > ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify) > END_MESSAGE_MAP() > > BOOL CMyDialog::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * > pResult ) > { > TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; > UINT nID =pNMHDR->idFrom; > if (pTTT->uFlags & TTF_IDISHWND) > { > // idFrom is actually the HWND of the tool > nID = ::GetDlgCtrlID((HWND)nID); > pTTT->hinst = AfxGetResourceHandle(); > switch (nID) > { > case IDOK : pTTT->lpszText = "OK Button"; > return TRUE; > case IDCANCEL : pTTT->lpszText = "Cancel Button"; > return TRUE; > default: return FALSE; > } > } > return FALSE; > > } > > AliR. > > > "Mark Foley" <foleym(a)meftechno.com> wrote in message > news:45db75de$0$8969$4c368faf(a)roadrunner.com... >>I have an array of 32 tooltip controls because I have 32 LEDs. The tooltip >>for a given LED is not >> always enabled, hence Activate() must apply only to a given >> control/tooltip. >> >> The question is how can I update the text when the cursor is placed over >> the control such that the >> tooltip pops up current information? >> >> Thanks! >> >> "AliR (VC++ MVP)" <AliR(a)online.nospam> wrote in message >> news:HSJCh.15994$O02.15608(a)newssvr11.news.prodigy.net... >>> Did you specify a problem in this post? I read the entire thing but did >>> see a question! >>> Is the question why m_POLErrorInfo[i].HitTest() return TRUE all the >>> time? That all depends on what your AddTool method looks like? >>> >>> Why do you have an array of CToolTipCtrls? You should have one pre >>> dialog and add multiple tools (control) to it using AddTool. After you >>> do that CToolTipCtrl::HitTest will return the control id of the control >>> under the mouse. >>> >>> As far as your OnToolHitTest goes you should return pTI->uId if you want >>> to change the tooltip or -1 if you don't. (The doc is wrong on that you >>> have to return 1). >>> >>> >>> AliR. >>> >>> "Mark Foley" <foleym(a)meftechno.com> wrote in message >>> news:45db63ac$0$1372$4c368faf(a)roadrunner.com... >>>> Can comeone please explain to me why this seems to not work as >>>> advertised? >>>> I have seen countless examples which go to great lengths to implement >>>> what I want to do and which seems as if it should be quite simple. >>>> >>>> I have multiple IPictEditor controls which are a simple LED box >>>> on a dialog. >>>> >>>> I have created and added a CToolTipCtrl for each one. All of this works >>>> perfectly - the tooltip pops up just like I want it to. >>>> >>>> Periodically I update the tooltip text using UpdateTipText(). No >>>> problem there. >>>> >>>> What I would like to be able to do is update the text when the user >>>> moves >>>> the cursor over the tooltip area. >>>> >>>> The documentation for the CToolTipCtrl class seems to indicate that >>>> this >>>> should be as simple as: >>>> >>>> 1. Override OnToolHitTest() ie. INT_PTR CMon::OnToolHitTest(CPoint >>>> point, TOOLINFO* pTI) const >>>> >>>> >>>> INT_PTR CMon::OnToolHitTest(CPoint point, TOOLINFO* pTI) const >>>> { >>>> >>>> BOOL res; >>>> CToolInfo m_ToolInfo; >>>> >>>> TRACE("\n Point %d, %d Hit",point.x,point.y); >>>> >>>> for (int i=0; i<IBS_MAXIMUM_POL_COUNT; i++) >>>> { >>>> // Get the ToolInfo about this Tool >>>> if (m_POLErrorInfo[i].GetToolInfo(m_ToolInfo, >>>> GetDlgItem(IDC_RUN_0+i))) >>>> { >>>> if (m_POLErrorInfo[i].HitTest(GetDlgItem(IDC_RUN_0+i), point, >>>> (LPTOOLINFO)&m_ToolInfo)) >>>> { >>>> TRACE("\n Tooltip for POL %d is hit",i); >>>> // I should be able to call UpdateTipText() to update my text... >>>> } >>>> >>>> } >>>> >>>> } >>>> return Dialog_Brush_Base::OnToolHitTest(point, pTI); >>>> } >>>> >>>> >>>> >>>> The HitTest always returns true, regardless of where the cursor is. >>>> GetToolInfo() correctly returns info about my tooltip. >>>> >>> >>> >> >> > >
|
Next
|
Last
Pages: 1 2 Prev: DISPLAY BITMAP, GIF, JPG in MFC Next: converting icon to bitmap in memory |