Help - Search - Members - Calendar
Full Version: Controlling main window resizing/moving
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
mixcherry
So, I am trying to write my first plugin for foobar2000 - something that would snap the main window to the edge of the screen, when the window is, let's say, 10 pixels away from the edge.

I would like to get information about position and size of foobar2000's main window, whenever it is being moved or resized. I think this should work like processing WM_SIZING (or WM_MOVING) message in normal Win32 application, but I really don't know how to get this message in my plugin? (actually, I don't think it is possible that way)

Any hints on how could I get that sort of information?

PS. Oh, and many thanks to foosion for his 'Plugin development tutorial' - it made a lot of things really easier to understand!
FrozenSpoon
There are many ways of doing this.
I would do something like:

On startup, get the HWND of the main foobar window using core_api::get_main_window() and get the threadID of the main foobar thread using GetCurrentThreadId(). Install a hook to monitor the messages of the foobar thread using SetWindowsHookEx() (and be careful, that can be dangerous).

You can then monitor when foobar moves, know it's new location and size, and then change just about anything with the window you want using the HWND you got.

Edit: Just wanted to say, this is pretty dirty smile.gif But I don't think that foobar exposes any cleaner methods.
mixcherry
Thanks for your reply, it's very helpful!

But, may I ask, why do you call it 'dirty'? Is there any possibility that it could break stability of main application? Why this can be dangerous?
Peter
Hooking main window events is not a part of documented API and is likely to break when more than one component does it, not to mention possible problems when user changes loaded UI module (which includes main window implementation) to something else. Components that do it will be added to offender list on first sight. Features you want to add should be implemented in UI module itself instead.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.