PDA

View Full Version : catch minimize of main window


modziw
28th February 2012, 09:22
does anyone know how i can execute an action whenever winamp is minimized? my c++ is shit and i can't seem to find a single example of how to receive this kind of a message from the window

there are examples of the reverse -- say to minimize the window. but i want to know when the user minimizes the window, so that i can execute a particular function, and then when winamp is restored, to execute another function.

specifically, i am hoping to have a gen_plugin that loads a different visualizer when winamp is off the screen (keyboard_led_flasher) and then fires up the spectrum analyzer again when back on screen

i've tried loops and switches with IPC_ISWNDVISIBLE but then winamp hangs while the loops wait for focus...

maybe there is a way to use windows messages like WM_ACTIVATEAPP, but could anyone help me figure out how to do it so that winamp doesnt hang?? i was working inside init() but its my first plugin for winamp i really have no idea whats what

appreciate any help :)

cheers m8s :igor:

thinktink
28th February 2012, 19:48
If you want to poll the main window's state you would either need to do it by checking it from a timer message/function or by doing it with an intermittently sleeping thread. However I would not go polling (especially in a loop called from the context of the main UI thread) if I didn't need to.

You can either subclass the main window or hook the main window and then look for one, some, or all of the following messages:
WM_SIZE
WM_SYSCOMMAND

DrO
28th February 2012, 21:10
using a hook would be the only safe way to do it with the scenario presented of this being for a visualisation plug-in.

-daz

thinktink
28th February 2012, 21:24
using a hook would be the only safe way to do it... ...visualisation plug-in.

Oops, hah, nice catch DrO. Forgot about that.