INTERACT FORUM
Windows => Plug-in Development => Topic started by: Reonekot on December 16, 2010, 05:21:25 am
-
I'm playing around with a MediaJukeboxAutomation plug-in for the Snarl notification system and have run into a small problem I can't seem to solve. When Snarl is started or exits it sends a global Window message to all top level Windows. In my plug-in I need to catch this message, so I can register with Snarl. But since my MJ UserControl (C#) isn't a top level Window, the control doesn't get the message. I tried creating a new form and setting it's TopLevel property to true, but that didn't work either for some reason.
Anyone has an idea to how I can get the global broadcast message from .NET, without hooking MJ's message loop?
-
I have a similar issue :(
-
My problem actually mostly boiled down to me running MJ as administrator (because I launched it from an elevated Visual Studio) and Snarl running non elevated. What I have now is a .NET NativeWindow (http://msdn.microsoft.com/en-us/library/system.windows.forms.nativewindow.aspx) and that works fine when both sender and receiver runs non elevated.
-
I fixed it by using user32.dll's, and intercepting the WindProc messages, doing what I need with them, and then returning them to MC.
Did you just make your plug-in inherit the NativeWindow class, instead of the UserControl class?
-
Ohhhh nevermind, I thought you meant intercept Media Center's messages. You just want to intercept the messages sent to your control, from looking at the NativeWindow class... unless I'm making a fool of myself here....
-
My problem was about getting my plugin to catch global windows broadcast messages (messages registered through RegisterWindowMessage()) - a it all boiled down to running receiver and sender running under different user rights. (Elevate vs. non elevated)
Anyway, to hook MJ/MC can't you just create a NativeWindow and Attach it via the MJ/MC window handle? (Don't know if this is what you already did...)
-
Perhaps... I looked into using NativeWindow, didn't really seem to be many obvious examples that do something like intercept a different handle's messages (although a few intercept their parent forms messages), but the examples I found for doing it with user32.dll were all over the place, so I guess that's what I went with... seems to work very well though, and basically allows me to intercept messages for any window handle I have (obviously, when I need messages for the plug-in, I just override WndProc, however).
Also, NativeWindow seems to be for pop-up windows, am I incorrect on this? I don't need a pop-up window, so if that was the case it wouldn't be necessary. IDK, MSDN is a little sketchy on this....
-
Looking at the documentation it looks like NativeWindow will only allow you to hook a window in the same process, but if the window is in the same process it should work fine I think. (Not sure where you found it only works for windows with POPUP style?) Anyway, NativeWindow is probably just a wrapper around P/Invoke stuff.