 |
|
 |
Using WinXP32 Pro SP2, VS2005 Pro SP1. Demo executable works fine, but added to my pgm doesn't work (no balloons appear). I wonder if this is because I am using "normal" tooltips in my MFC project.
My code:
CBalloonMsg::Show("GREETING","Hi");
Stepping through with debugger, I see
CBalloonMsg::Create(NULL)
GetWndClass
CToolTipCtrl::CreateEx(CBalloonMsgWnd hWnd=0x50978,67,0) returns 0 (failure)
Within CreateEx:
CToolTipCtrl::Create
AfxDeferRegisterClass returns 1
CWnd::CreateEx(0,"tooltips_class32",NULL,0x80000043,0x80000000,0x80000000,0x80000000,0x80000000,0x50978,NULL,NULL)
(x,y,nWidth,nHeight all 0x80000000)
PreCreateWindow returns 1
AfxCtxCreateWindowEx returns hWnd=0x100B24
AfxUnhookWindowCreate returns 1
ModifyStyleEx(0,0) returns 0 (failure)
SendMessage(TTM_ADDTOOL) returns 1
SetTitle returns 1
m_bReposition = 0
SendMessage(TTM_TRACKACTIVATE) returns 1
SetTimer(1,30,NULL) returns 1 (do you mean to check every 30 msec?)
The only TRACE output is "STARTING: CBalloonMsgThread"
Any ideas what's wrong?
|
|
|
|
 |
|
 |
Very nice. I'm using this control to display extra information when a user clicks on a custom control I wrote. The user can click in many places in rapid succession to very properties of those locations (think viewing the locations on a map). Anyway, the default version of the code would display several balloons at the same time. I needed a way to close all existing balloons. What I did was add a CWnd* parameter to the CBalloonMsg::Show() function, with a default value of NULL. That value is passed to the CBalloonMsgThread that is made in Show(). Then in CBalloonMsgThread::InitInstance(), I send a custom message to that CWnd, with the HWND of the tooltip control as its LPARAM. The CWnd (I've used my custom control as the handler, can be anything) has a handler for that message. It stores the HWND in a vector. Finally I have a function called CloseAllTooltips(). It contains this:
for (size_t i = 0 ; i < m_ToolTips.size() ; i++) {
HWND wnd = m_ToolTips[i];
::SendMessage(wnd, WM_CLOSE, NULL, NULL);
}
m_ToolTips.clear();
So now when I need to close the outstanding tooltips (in my case there is only one since I always close all before showing a new one), I can call this function.
|
|
|
|
 |
|
 |
I try to write a program with a taskbar button and modified you source code. I want to see the balloon message point to the icon on the system tray when I click taskbar button. But I have not made it ok yet. So I leave this message so that everyone help me to solve this problem. Please help me to make it. Thank you very much!
(I'm sorry. I'm not good at English)
|
|
|
|
 |
|
 |
For VC6, when defining cTTM_SETTITLE, you need to take account of Unicode:
#ifdef _UNICODE
#define cTTM_SETTITLE (WM_USER + 32)
#else
#define cTTM_SETTITLE (WM_USER + 33)
#endif
Great class, thanks!
|
|
|
|
 |
|
 |
Thanks David - much appreciated!
|
|
|
|
 |
|
 |
When Building an MFC application,there is nothing.The tooltip show truly.But in an MFC rugular DLL project,I create a dialg and test it,the
tooltip can not show.
|
|
|
|
 |
|
 |
Just to check my understanding: does the problem show up in a project that produces a DLL, or just in a project where MFC is linked as a DLL (as opposed to static linking)?
I haven't checked either of those scenarios yet - I always use static linkage to avoid any DLL-hell problems, but I'll look into it as soon as I get a bit of free time.
|
|
|
|
 |
|
 |
In my app, the balloon disappears much to soon, even if i don't move the mouse (the balloon is displayed 'far away' from current mouse pos, but i'm not sure that this is a reason. Solution/Workaround:
case TTN_POP:
{
/* // The tooltip is closing - let's make sure our thread does likewise
TRACE( "CBalloonMsgWnd: Closing due to TTN_POP\n" );
::PostQuitMessage( 0 );*/
*pResult = 0;
return TRUE;
}
i just commented this PostQuitMessage....
sideeffect: moving the mouse does not hide the tip anymore... does anyone have a better solution?
btw.: Thanks for the code !
|
|
|
|
 |
|
 |
Hi RedFraggle - can you tell me which version of the code you're using? When I tested the most recent update I found that TTN_POP wasn't firing at all, but I left it in just in case...
|
|
|
|
 |
|
 |
i upgraded to the most recent version, the same day i posted the message.
I did not use it as static call CBallonMsg::Show() but i made a member variable and used it via m_aBallonMsg.Show(...), maybe thats a problem... i will try it again when i get some time.
additional infos:
OS: WinXP SP2, maybe no manifest used (i included it, but it seems not to work)
WIN_VER increased from 0x500 to 0x501, no difference as far as i noticed...but i'm not quite sure
The popup is shown exactly like a 'normal' tooltip... (yellow)
|
|
|
|
 |
|
 |
Paul,
Great job! I've always wanted to have an unobtrusive way of showing an error in input for dialogs. Showing balloon tips over controls seems to be the right answer. I've also seen the other implementation, but found it a bit flaky.
Anyways, I've modified your classs a bit to compile on VC6 without Windows SDK headers. I can send you the project if you want. It also has a suggested fix for registry hack. Basically I check if registry key is set to non zero value, then I display AfxMessageBox (with warning, error or info icon), otherwise it will show balloon.
Thanks,
Damir
|
|
|
|
 |
|
 |
That sounds great - why don't you mail it to me (I've sent you my email address privately) and I'll pop it up with my next revision of the article?
|
|
|
|
 |
|
 |
It seems like the "email reply" system is broken on this site because I didn't get your message. So maybe just send me e-mail and then I'll send you the files. My address is XXXXXXXXX
|
|
|
|
 |
|
|
 |
|
 |
1. Instead of using a CWnd*, why not use an HWND to the nominated control for the ShowForCtrl method?
2. Overload the AfxMessageBox function to receive a handle to the nominated control, along with the normal AfxMessageBox parameters. The implementation of the new AfxMessageBox could call CBalloonMsg::ShowForCtrl if themes are enabled, if not, then call the real AfxMessageBox. It could, based on the nType parameter, determine which icon to use in the tooltip. This would truly make your tooltip control a true alternative to AfxMessageBox.
Nice work, BTW!
|
|
|
|
 |
|
 |
#1 - yep, I'll try to remember to add a version that takes a HWND
#2 - Nice idea, very nice. I'll take a look at that this weekend.
|
|
|
|
 |
|
 |
1. Unlike the screenshot, when you click the Test button, the balloon pops up underneath the edit box, pointing up. I don't see anything obvious in the class, like an "orientation" setting. Is there any way to control how the balloon pops up?
2. Clicking on the dialog background doesn't close the balloon, although clicking anywhere else (caption, balloon, edit box) seems to close it. It seems like clicking on the dialog background should close the balloon too.
|
|
|
|
 |
|
 |
1) Balloon orientation
Yep, I should probably update the screenshot.
In the first version, I used non-tracking tooltips. The balloon appeared above the ctrl BUT it's behavior was less than brilliant when the dialog was near a screen edge. In the bottom right corner of the screen, the balloon pointer was severely off target. Near the top edge of the screen, the balloon sometimes inverted and again the pointer didn't point to the right place.
The new version uses tracking tooltips and appears to be consistent and reliable, but for some reason MS decided that the default orientation should be below the target point, except in cases where the balloon won't fit on screen - e.g. when near the lower edge of the screen. As far as I can see, there's now way to change this, and I have spent a fair bit of time looking for one.
2) Click on dialog background
Yep that's a good point. I'll see if I can add that next weekend. The complication here is that with a standard tooltip, the ctrl takes care of closing on mouse activity. With a tracking tooltip, it needs to be coded explicitly.
Cheers
|
|
|
|
 |
|
 |
I believe the reason for everyone not seeing it is because they likely used a tweak utility or modified the registry setting for balloon tips on the taskbar. Your code uses the technique that requires this to be enabled to see them.
Go to the following location in your registry
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
and change the DWORD value for EnableBalloonTips from 0 to 1 and that should fix the problem
|
|
|
|
 |
|
 |
Many thanks for that - I hadn't even considered that a registry tweak might be involved!
I'll check it out and maybe put a warning into the class if balloon tips have been disabled.
|
|
|
|
 |
|
 |
I've updated the source and demo downloads with a new version that uses tracking tooltips. In tests on my PC, this seems to get round problems with the balloon pointer when the parent window is near a screen edge. It also allows the balloons to stay up indefinitely if required (as requested by Hans Dietrich).
It may also help in the cases where folks aren't seeing the balloon at all, and even if it doesn't, there are extra traces in this version that could help if the problem persists on those systems.
|
|
|
|
 |
|
 |
Hi,
Nice app.
Small problem, clicking the OK button shows the balloon pointing to the OK button, not the text box.
I tested the precompiled app on xp sp2.
|
|
|
|
 |
|
 |
Thanks for letting me know!
I can't get this to happen on my test system - does the same thing happen when you press the "Test" button rather than the OK button? And could you tell me whether you're using the mouse to hit the OK button or using the Enter key?
|
|
|
|
 |
|
 |
This happens when I use the mouse to click the OK button, clicking the test button with the mouse is ok.
If I push enter when the app launches (the OK button is in focus) then the position of the balloon is ok also.
|
|
|
|
 |
|
 |
Thanks for the info!
I've finally managed to reproduce this one by moving the dialog close to the lower right hand edge of the screen. I'll put some time into it tomorrow and hopefully get a solution.
|
|
|
|
 |