2nd strange bug /tokenmousehover vista

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Version: 3.1.0216
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Avatar
I have a project.. when i create syntax editors (v3.1 - 216) dynamically and hook up the TokenMouseHover event manually.. on XP , 95% of the time the mousehover on the token works fine, and i get my nice tooltip sort of things i use. however over the last 6 months when using my app, i've noticed that sometimes it doesn't work.. i thought maybe something to do with a bad system, windows resource usage.. and rebooting the machine would ussually fix it, however other tooltip stuff worked at the same time.. anyhow it worked most the time so i ignored it.. but i did notice that it was actually over a number of machines that it would sometimes not work..

but today, i've been working on making sure all is well with the app on vista, and it NEVER works on vista.. so i poked deeper.. and the actual MouseTokenEvent Doesn't even fire, at all in this case (however in a simple test app i created with one static syntaxeditor control, it fird fine on vista), but not in my app..

i added a menuitem, to add the event again and again and it just won't fire, under any circumstance...

an interesting note, just now on my XP box its misbehaving as well, but it seems to be firing maybe one out of 50 times i hover over a token.

one thing about my app, is that i have 2 different and distinct syntax editor controls on the form at the same time, maybe that is a factor.

this here is a key aspect in my application.. my next steps in trying to isolate it, is to look at tokenmouseenter and tokenmouseleave and see if they are firing as well.. and to make a simple example, that has 2 syntax editors on the form (and see if i can reproduce the error simply on vista)..

another thing to note is the syntax editor is not "directly" on the form.. but inside a winforms usercontrol.

-Karl

Comments (20)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Can you also try this with the maintenance releases that came out today? I wasn't able to duplicate any issues with the tooltip showing when using the maintenance release from today.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
just tried it, and sadly it behaves the same
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Please refer to your other posting, as I'm thinking that for some reason you are still pulling in the old build.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
now that the other problem is fixed, this is still misbehaving..

the tokenmousemove event just doesn't fire on vista in my context (the context of the of multiple syntax editor controls on the form, and they themselves being inside usercontrols).. for in a simple application this event is firing fine in vista, just not in mine

the strange thing is i can subscribe to this event many times, and its not fired.. however TokenMouseEnter and TokenMouseExit are firing fine.. However do you calculate when to raise the tokenmousehover event? something like 500ms after enter if exit hasn't happened or if another token hasn't been entered?


anyhow , i'll try to build a small app to simulate my situation, though it might not be possible.. If you have powershell installed on your vista computer, i can give you my binaries so you can see where it is not working.. if we can't narrow this down, i can always simulate my own tokenmousehover with some custom code in the tokenmouseenter and tokenmouseexit events.

-Karl
Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
so i have really narrowed it down.. I spend a good number of hours trying to replcate the problem in a demo app, adding about 20 things unique to my application, but still it would work fine on vista, until i did one thing...

i use infragistics netadvantage GUI controls. and the syntax editor control put inside a container (tabcontrol) of that control.. it seems thats its only the TokenMouseHover (not enter or exit) that is affected, and only on your control. (i.e if i put a dotnet textbox in there, the mousehover event fires fine)
and it only misbehaves on vista (it works fine on XP).

so i don't know whose at fault (infragistics, or your control, or microsoft), i think probably an odd combination, with different ways on handling the windows messaging in parent/child containers.. i don't knnow how much you want to proceed in debugging, and trying to fix that.

i've uploaded the test project here..
http://karlprosser.com/tempshare/hoverbugtest2.zip

you mightn't be able to compile it without infragistics, however you can go to the release directory and run the app.. at the top i put syntaxeditor inside a standard tab control and when you type in something then hover over it, you'll see the textbox below showing the token..

however at the bottom is syntaxeditor inside an infragistics tabcontrol and it doesn't work on vista (though it will work on XP)

Do you think you'll investigate to fix this? or not? if not i can probably work around by writing my own hover logic just using the TokenMouseEnter and TokenMouseLEave events.

anyway here is a link to the project with the compiled code in the bin\release directory.

-Karl
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Karl,

When I run the alternate test app that you provided via chat, it was working for me in both XP and Vista. I was able to see different token names listed when hovering over identifiers and whitespace, even within the Infragistics tab control.

We can discuss over chat some more if you'd like.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
Ok, i've narrowed it down even further, if i turn aero off (go to windows classic on vista).. the WORKS.. it just doesn't work with AERO..
Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
so i tried your suggestion of decending from syntaxeditor and overriding the OnMouseHover method and seeing if it fires, and it doesn't fire.. so really there is nothing you can do about it.. its just an intersting combination of an infragistics container, your control, and Vista WITH AERO..

when i put different controls (i.e winforms panel, or richedit, or richedit in a panel, inside an infragistics control , its mousehover event fires fine.. so i don't know what it is about the combination of your control and infragistics control that don't work.. I don't know if there is anything further you can do?, and since i can't make a simpler example of it failing (with a different control than yours) i don't know if i can submit anything to infragistics, i think my safest bet is just to hack around it, and just ignore the tokenmousehover and just base my logic off tokenmouseenter and exit

what do you think?

Karl
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
So if you make a blank control that inherits Control and override OnMouseHover and place it in their tabstrip, do you get the OnMouseHover to fire in that case? That should mimic what our control does. In addition, remember in the chat that I mentioned the ResetMouseEventArgs call in OnMouseMove too.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
ok, i made a quick and dirty control to test this, and it behaves EXACTLY like your control.. ResetMouseEventArgs() is what does it.. if i take that out.. it works fine..

anyhow the behaviour is , that When this control is on vista with AERO theme and inside an infragistics control, the onmousehover is not fired.. (however if its on a standards winform control, or on XP, or vista with classic theme it works fine.

public class mycontrol : Control {
protected override void OnMouseHover(EventArgs e) {
MessageBox.Show("OnMouseHover Fired");

base.OnMouseHover(e);

}
protected override void OnMouseMove(MouseEventArgs e) {
base.OnMouseMove(e);
ResetMouseEventArgs();
}
}

i suppose resetmouseeventargs call is critical to your logic?, i will submit this to infragistics but prob won't get movement very fast there. what i need is a workaround for your control.. initially i thought i could do a work around since tokenmouseenter and tokenmouseexit fire.. so i did something like this

i have a timer set to 100ms

and the following code

public TokenMouseEventArgs lasttokeneventargs;
private void editor_TokenMouseEnter(object sender, TokenMouseEventArgs e) {

HoverTimer.Enabled = false;
lasttokeneventargs = e;
HoverTimer.Enabled = true;
TokenStatus.Text = "entered " + e.Token.Key;
}

private void editor_TokenMouseLeave(object sender, TokenMouseEventArgs e) {
HoverTimer.Enabled = false;
lasttokeneventargs = null;
TokenStatus.Text = "left " + e.Token.Key;
}

private void HoverTimer_Tick(object sender, EventArgs e) {
HoverTimer.Enabled = false;
lasttokeneventargs.ToolTipText = "test";
TokenStatus.Text = "hovering " + lasttokeneventargs.Token.Key;
}

here from my status, the events (entering , leaving and my fake hovering are working fine, however i can't get the tooltip to come up , probably because the TokenMouseEventArgs , which i am keeping a reference to in the Enter method is not valid after Enter has finished? so can you suggest a suitible workaround, where i can get a tooltip popup to work outside of TokenMouseHover (which doesn't work for me on vista etc)..

Much Appreciated,

Karl
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Just for more info, the reason for the ResetMouseEventArgs call is due to an issue with how MouseHover fires. Namely, normally it will only fire once after the mouse enters a control and will not fire again until you leave the control. Obviously that makes the event almost useless for things like tooltip display, etc. where the end user moves the mouse and hovers over many areas of a control before leaving it. So calling ResetMouseEventArgs is a workaround for this issue per posts such as this:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=515462&SiteID=1

You will need to call the SyntaxEditor.OnMouseHover method to get the tooltips working. So in your hover event handler, maybe call a RaiseMouseHover method that you implement in a class that inherits SyntaxEditor and calls the protected OnMouseHover.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
that sounds like a good solution, other than one facet... if i call SyntaxEditor.OnMouseHover, that will raise the tokenmousehover event right? well on a XP system would that mean that the tokenmousehover event is going to be called twice? (because the control will work normally on XP?)
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes but you could check the Windows version before doing this. I think either the Environment or SystemInformation class has info on the system that it is being run on.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
not only windows version though, but the theme, whether it is aero.. and then if other themes come out that are not classic (i.e with a windows plus pack) i'd have to be able to tell that.. and then maybe a windows update might fix the problem in the future.. its not really a hack i am comfortable with. I will do what i have to, but i want to explore possibilities of a more stable and reliable workaround.
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I will mark down to look into it more. It really stinks that MouseHover never performed like you would expect to start with, thus requiring that ResetMouseEventArgs workaround.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
yep, maybe you could not use the windows onmousehover , but intercept the windows messages directly or implement my kind of work around as the main technique inside syntaxeditor, if its proves to be a solid technique, and that way mousetokenhover would only be fired by this technique.. i don't have a clue which is best...
Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
i threw together the following decendant class of syntaxeditor and it seems to work well on first glance. basically i override OnmouseHover and totally ignore it, and have my own timer internal that i calculate with tokenmouseenter and leave, and call OnTokenMouseHover accordingly.. the 1st question is do you use the editorwide OnMouseHover for anything other than finding that a token is hovered? if so then this technique of mine might have bad and unforeseen sideeffects, and the 2nd question, is if you don't then maybe making a similar technique yourself inside syntaxeditor might be a better hack than the reseteventargs?

anyhow, your thoughts and wisedom are sought, and will be duely appreciated

public class mysyntaxeditor : SyntaxEditor {
private Timer mytimer;
public mysyntaxeditor() : base() {
mytimer = new Timer();
mytimer.Interval = 500; //make a long hover wait so its easier to notice when testing
mytimer.Tick += new EventHandler(mytimer_Tick);
mytimer.Enabled = false;
}

void mytimer_Tick(object sender, EventArgs e) {
mytimer.Enabled = false;
OnTokenMouseHover(lastargs);
}
TokenMouseEventArgs lastargs;

protected override void OnTokenMouseEnter(TokenMouseEventArgs e) {
mytimer.Enabled = false;
base.OnTokenMouseEnter(e);
lastargs = e;
mytimer.Enabled = true;
//OnTokenMouseHover(e);
}
protected override void OnTokenMouseLeave(TokenMouseEventArgs e) {
mytimer.Enabled = false;
base.OnTokenMouseLeave(e);
}
//we don't even need this
/*
protected override void OnTokenMouseHover(TokenMouseEventArgs e)
{
base.OnTokenMouseHover(e);
// MessageBox.Show("it hovers");
}
*/


protected override void OnMouseHover(EventArgs e) {
// don't call anything here so that we don't get the double up on XP
// (i.e we won't use windows hovering at all, just our own hovering calculations
// base.OnMouseHover(e);
}


}
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
As long as you call base.OnMouseHover it should work ok. The UIControl.OnMouseHover distributes the event to its child UIElements (one of which in this case is EditorView) and EditorView processes its OnMouseHover to know when the mouse hovers over tokens or a smart tag.

Ideally we'd like to stay away from Timers if we do it on our own and use that windows message somehow instead. Timers add resources, which in SyntaxEditor's case is probably ok, but our base UIControl is used by all our other products as well all over the place. So we don't want to increase memory resources there if possible.


Actipro Software Support

Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
>>>As long as you call base.OnMouseHover it should work ok. The UIControl.OnMouseHover distributes the event to its child UIElements (one of which in this case is EditorView) and EditorView processes its OnMouseHover to know when the mouse hovers over tokens or a smart tag.

as you can see from the code below


protected override void OnMouseHover(EventArgs e) {
// don't call anything here so that we don't get the double up on XP
// (i.e we won't use windows hovering at all, just our own hovering calculations
// base.OnMouseHover(e);
}

i'm NOT calling onmousehover, because that would create the double up in XP.. i see that i should since there are other UIelements that may use the hover event? ((what are smart tags b.t.w?) so my not calling onmousehover would break your code there.
Not sure the best workaround is.. UNless you can show me our onmousehover() code, and if there is a way with just referencing protected (rather than private fields) i can duplicate it, WITHOUT calling the token hover handling code. Or maybe you know another way i can override things more elegantly?


-Karl
Posted 18 years ago by karl - Senior Software Architect, Shelltools, LLC
Avatar
infragistics today just released a hotfix package which seems to have fixed this problem. Yay, i don't need to do any hack.. Thankyou for working this with me

-Karl
The latest build of this product (v24.1.1) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.