 |
|
 |
The MessageBalloon has the potential to stay put until you close it or the user closes it. That is good for longer messages.
Problem: If the user activates another app or clicks Next on a Wizard, the MessageBalloon stays right there, but now it's pointing at something else!
I know the HoverBalloon could be used, since it is built to kill itself after x seconds, but in that case, the programmer is trying to guess how fast the user can read!! For longer messages, the user is reading the message when it disappears. Not appropriate.
So, I've used a module-level variable to hold the ref to the MessageBalloon, so that when the user does something like bring another app to the front, I can kill the MessageBalloon. Unfortunately, I have to put code everywhere to kill the MessageBalloon, such as in the FormClosing event, or in other button_click events, etc. etc.
Has anyone found a better way to ensure that the MessageBalloon gets closed when the control it is pointing at becomes obscured or another app gets focus?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
I suggest you looking into parent form events.
public MessageBalloon(Control parent) { m_parent = parent; m_tool = new MessageTool(); m_tool.DeActivate += new DeActivateEventHandler(this.Hide);
Form parentForm = parent.FindForm(); parentForm.Deactivate += new EventHandler(ParentFormDeactivate_EventHandler); parentForm.HandleDestroyed += new EventHandler(ParentFormDeactivate_EventHandler); }
private void ParentFormDeactivate_EventHandler(object sender, EventArgs e) { Hide(); }
modified on Wednesday, August 19, 2009 9:33 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Looking at the code for the HoverBalloon, I don't see any clear way of setting the timeout for it to disappear. If the text is a bit longer, the user won't have time to read it before it's gone.
________ 42 is definitely not the meaning of life. I knew that when I turned 43.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Here's what I found that did work for setting the ballon duration to 10 seconds:
public const int TTM_SETDELAYTIME = (WM_USER + 3); public const int TTDT_AUTOPOP = 2;
[DllImport("User32", EntryPoint = "SendMessageA", SetLastError = true)] public static extern int SendMessage( IntPtr hWnd, int Msg, long wParam, long lParam);
SendMessage( m_tool.Handle, TTM_SETDELAYTIME, TTDT_AUTOPOP, 10000);
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks, sgennette,
I'm having a bit of trouble implementing your suggestion, can you show where you put the "SendMessage" call to implement this?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I put the code here;
Marshal.FreeHGlobal(ptrStruct);
SendMessage( m_tool.Handle, TTM_SETMAXTIPWIDTH, 0, new IntPtr(m_maxWidth));
SendMessage( m_tool.Handle, TTM_SETDELAYTIME, TTDT_AUTOPOP, 15000);
I'm still trying to understand these messages and where they should go. I have two labels that I'm using for the hover balloons and I can get one to work well but not both. Gotta figure it out.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I program in VB, and have used this project as a basis for a VB project.
When I include the code you have posted above, the HoverBalloon appears but disappears almost instantly.
Would you be inclined to have a look at my project and see if you can determine why this is? If so, please send me your email address to bobishkindaguy@hotmail.com and I'll send you a zip of the code.
Or if you prefer, please send me a zip of your working sample and I'll convert it to VB and see where mine differs.
Thanks very much. Bob
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hey, First - excellent post! Second, while I managed to run the code from a WPF application and everything works, I see the balloon with no visual styles (and no X button as well).
Do you know how can I overcome this? Thanks!
--sternr
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
This is a good control. However, I need to show the tooltip when user enters invalid data in a control. The best option for me would be edit tooltip. But when the control's validating event is cancelled, other controls are still working. Note that I have placed my control in a tab page. Its buttons are unexpectedly firing their events, but the tab pages and the form's close button are not working which is a desired behavior. Any clue!
|
| Sign In·View Thread·PermaLink | 3.00/5 (3 votes) |
|
|
|
 |
|
 |
I am using the a command button to trigger the show method of the edit tool tip. However the tooltip quickly appears and dissapears.
However, if i invoke the CommandButtun_Click even from the main menu the tooltip stays.
Any ideas?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Great Stuff Man!!! Here a new feature for you:;P
Since Microsoft Windows XP Service Pack 2 (SP2) and later you can add a custom Icon. In this way:
Icon should be 16 x 16 ....
CLIENT: mTip.Icon = this.Resourcer.LoadIcon("_1616").Handle
COMPONENT:
private IntPtr mIcon;
public IntPtr Icon { get { return mIcon; } set { mIcon = value; } }
SendMessage( mTool.Handle, TTM_SETTITLE, (int)mIcon, ptrTitle);
Cheers to the Community
Nicola
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
When you click twice on "Message Balloon"/"Show Tip" the tip does not get closed after clicking "Hide Tip", even the close button on the tip does not work any more... A comparable problem occurs when you click "Hide Tip" without ever having clicked "Show Tip".
H. Salomons
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Has someone implemented a timeout option .... like I want the balloon to close after 5 seconds. any tip/url?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Easy! Add this code in the balloon you want to auto-close:
private System.Windows.Forms.Timer timerToClose;
public MessageBalloon() { ... this.timerToClose = new Timer(); this.timerToClose.Interval = 5000; this.timerToClose.Tick += new System.EventHandler(this.timerToClose_Tick); this.timerToClose.Enabled = true; }
private void timerToClose_Tick(object sender, System.EventArgs e) { this.Hide(); this.timerToClose.Enabled = false; }
Quite simple, isn't it?
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
 |
I tried using the code you gave but it didn't work.
Here's what I found that did work for setting the ballon duration to 10 seconds:
public const int TTM_SETDELAYTIME = (WM_USER + 3); public const int TTDT_AUTOPOP = 2;
[DllImport("User32", EntryPoint = "SendMessageA", SetLastError = true)] public static extern int SendMessage( IntPtr hWnd, int Msg, long wParam, long lParam);
SendMessage( m_tool.Handle, TTM_SETDELAYTIME, TTDT_AUTOPOP, 10000);
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
I am using DotNet v1.1. there seems to be strange problem with OpenFIleDialog, SaveFileDialog and FolderBrowseDialog. When I show a ballon tooltip and one of the dialog is also displayed, a strange NullReferenceException creeps in. I have tried to hide and dispose the ballon tooltip before opening the dialog. Any suggestions?
-Kashif
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I had exactly the same problem, i've identified the problem to be in the SetToolTip() method
---> SendMessage( m_tool.Handle, TTM_ADDTOOL, 0, ptrStruct);
NULL REFERENCE EXCEPTION !!
Can anyone figure it out ??
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Please look at the dates posted. It looks like MSDN has copied the code from this article! I posted this in Sept 2003 and the MSDN article is from March 2006. Having said that I do acknowledge there are bugs in the article and that I havent been able to getting to fix them. I appreciate the community effort in fixing them. Thank you everybody.
|
| Sign In·View Thread·PermaLink | 5.00/5 (3 votes) |
|
|
|
 |
|
 |
There is a bug in the Show method of the EditBalloon class. This causes an intermitent AccessViolaitonException under the .NET Framework 2.0.
The offending lines are:
IntPtr ptrStruct = Marshal.AllocHGlobal(Marshal.SizeOf(ebt)); Marshal.StructureToPtr(ebt, ptrStruct, true);
The second line should be: Marshal.StructureToPtr(ebt, ptrStruct, false);
You cannot instruct Marshal.StructureToPtr to delete the previously used buffer, since the buffer has not been previously used. The line before this line allocates a new buffer, which contains unpredictable data. This causes the AccessViolationException to occur intermitently.
From MSDN:
If the fDeleteOld parameter is true, the buffer originally pointed to by ptr is deleted with the appropriate delete API on the embedded pointer, but the buffer must contain valid data.
The important part of that is "but the buffer must contain valid data" - you cannot delete an uninitialized buffer.
|
| Sign In·View Thread·PermaLink | 4.00/5 (3 votes) |
|
|
|
 |
|
 |
I'm using this component in an application and all went fine until I tried using the application in Windows Vista, where the application opened fine but, after a while, stopped working (never in the same place of the execution stack). After a few hours of debugging I came back to the component's page in Code Project and began looking through the messages until I found this one. I corrected de component's source code and the application no longer stopped working in Windows Vista. Thanks for the tip.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
How can i hide the EditBalloon?
I want to use this in some sort of advanced ErrorProvider...because i don't like the one in .NET, you have to hover the mouse over the small icon of the provider.
So I show the tooltip when there is an error and hide the tooltip if the control was validated.
Thank you, K
-- modified at 8:54 Tuesday 14th February, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |