AccessViolationException when trying to change IsBalloon in a Tooltip popup event

I create a form, add a Tooltip, and in the popup event-handler I call

toolTip1.IsBalloon = true;

toolTip1.GetToolTip(Form1.ActiveForm);

Compiling and then running the test program then results in an AccessViolationException after the program leaves the popup event-handler.

What I had planned to do is to use a single tooltip control that sets the IsBalloon property depending on what control called the popup event, instead of using one tooltip control that is not a balloon, and one that is a balloon.

I guess the same can be achieved by looking at what control the mouse pointer hovers over, but then I wonder how to change the property in a safe way as I suspect it's a threading issue.

Forgot to write that this is tested in Visual Studio 2005 Standard with SP1 Beta1.

[849 byte] By [Nekodar] at [2007-12-25]
# 1

Do not try to modify ToolTip in PopUp event handler, It'll give exception!

Try to use Controls MouseMove Event to change these property and you'll not see any exception!!!!

Best Regards,

RizwanSharp at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

Thank you.

And I just discovered this from the help files onToolTip.Popup Event:

Calling properties in this event that cause the underlying window handle to be recreated, such as IsBalloon, will result in an exception being thrown.

Nekodar at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3

Please Mark my post as answered so other can get benefit from it when the are searching for the same problem.

Best Regards,

RizwanSharp at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...