Is there a way in C# to globally add a menu item to all the system menus on all active windows? Perhaps under the "Maximize" command?
+2
A:
This can't be done in managed code. And it would be remarkably difficult even in unmanged code. Basically you would have to inject your code into every process, and then insert items into the local system menus, and then hook the main window proc to intercept the WM_SYSCOMMAND messages so that you could make the menu items do something.
You CAN write code that will add the WS_TOPMOST style to (most) windows (security permitting) just by using FindWindow
to get the window handle and then SetWindowLong
to change the window style.
But you won't be able to put the UI for this into other process's system menus.
John Knoeller
2009-12-22 03:37:32
Thanks for the reply John. So the best way to go at this is to write something like Spy++ that lets you "select" a window, then use SetWindowLong on that window to change the window style?
icemanind
2009-12-22 03:44:49
yep, that would be the way.
John Knoeller
2009-12-22 04:00:52