Using C#, I am looking to hook into the Windows API (I’m not sure which one) to capture which windows are being sent a maximize command. I want to then override that command to tell the window what the bound of the maximized window should be.
For example, when a user maximizes Notepad on an 800×600 screen, I want to specify the size that the window actually expands to. I might tell Notepad to “maximize” to 600×600 starting at position 200,0.
For this solution, it isn’t necessary that the window actually believe it is maximized, I just want to control the window so it doesn’t maximize to the whole screen (or that it restores itself automatically to the size I want if that is the best I can do).
As I stated, I want to control external applications (Notepad, Word, etc.) not my own application. I would prefer to write this application in C#. The actions I need to perform are:
- Capture maximize (or resize) events
- Readjust the changed window’s size
You’ll need to be hooking into the windows Message Loops (http://msdn.microsoft.com/en-us/library/ms632595(v=VS.85).aspx for documentation on the APIs you need). Overall, you’ll either be doing a ton of P\Invokes, or you’ll want to use C and the raw Win32 APIs.
I’m not certain, but I believe you will want to start by using a Windows Hook: http://msdn.microsoft.com/en-us/library/ms644990(v=VS.85).aspx