INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Receive Windows broadcast messages from plugin  (Read 4641 times)

Reonekot

  • Recent member
  • *
  • Posts: 5
Receive Windows broadcast messages from plugin
« 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?
Logged

danrien

  • Galactic Citizen
  • ****
  • Posts: 371
  • Chillin
Re: Receive Windows broadcast messages from plugin
« Reply #1 on: June 18, 2011, 06:22:43 pm »

I have a similar issue :(
Logged
http://davidvedvick.info

"Always be yourself. Unless you can be Batman. Always be Batman." - Anonymous

Reonekot

  • Recent member
  • *
  • Posts: 5
Re: Receive Windows broadcast messages from plugin
« Reply #2 on: June 19, 2011, 03:07:50 am »

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 and that works fine when both sender and receiver runs non elevated.
Logged

danrien

  • Galactic Citizen
  • ****
  • Posts: 371
  • Chillin
Re: Receive Windows broadcast messages from plugin
« Reply #3 on: June 20, 2011, 11:28:06 pm »

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?
Logged
http://davidvedvick.info

"Always be yourself. Unless you can be Batman. Always be Batman." - Anonymous

danrien

  • Galactic Citizen
  • ****
  • Posts: 371
  • Chillin
Re: Receive Windows broadcast messages from plugin
« Reply #4 on: June 20, 2011, 11:40:08 pm »

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....
Logged
http://davidvedvick.info

"Always be yourself. Unless you can be Batman. Always be Batman." - Anonymous

Reonekot

  • Recent member
  • *
  • Posts: 5
Re: Receive Windows broadcast messages from plugin
« Reply #5 on: June 21, 2011, 02:17:03 am »

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...)
Logged

danrien

  • Galactic Citizen
  • ****
  • Posts: 371
  • Chillin
Re: Receive Windows broadcast messages from plugin
« Reply #6 on: June 22, 2011, 08:20:42 pm »

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....
Logged
http://davidvedvick.info

"Always be yourself. Unless you can be Batman. Always be Batman." - Anonymous

Reonekot

  • Recent member
  • *
  • Posts: 5
Re: Receive Windows broadcast messages from plugin
« Reply #7 on: June 23, 2011, 02:38:23 am »

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.
Logged
Pages: [1]   Go Up