Cakes
お前はもう死んでいる
VIP
Retired
I'm working on a little application for fun, and have come to a standstill. Due to my limited experience with the Windows API and system-wide hooks in C#, I'm not entirely sure what steps to take next.
My application can currently retrieve the hWnd (the window handle) of whatever window you focus on. When a window is maximized or minimized, that window's WndProc will send a WM_SYSCOMMAND (0x0112) Message with a WParam of SC_MAXIMIZE (0xF030). This indicates that the window was maximized. What I need to do is somehow hook the focused window's WndProc, and intercept messages that are sent and fire my callback when the expected messages arrive.
I can currently monitor the WndProc messages for the above of my own application by overriding its default WndProc method:
I believe hooking the foreign window's WndProc will be the way to go. However, I also believe I can use SetWindowsHookEx or SetWinEventHook from user32 to also achieve this. I currently am already using SetWinEventHook to capture the hWnd of a window when it becomes focused. I tried to use SetWindowsHookEx to do the same, but it seemed to be really hard to do in C#, so I went with SetWinEventHook instead.
Any help would be appreciated.
lowpro S7 Pro
Edit: there is some more information in this post.
My application can currently retrieve the hWnd (the window handle) of whatever window you focus on. When a window is maximized or minimized, that window's WndProc will send a WM_SYSCOMMAND (0x0112) Message with a WParam of SC_MAXIMIZE (0xF030). This indicates that the window was maximized. What I need to do is somehow hook the focused window's WndProc, and intercept messages that are sent and fire my callback when the expected messages arrive.
I can currently monitor the WndProc messages for the above of my own application by overriding its default WndProc method:
PHP:
protected override void WndProc(ref Message message)
{
if (message.Msg == 0x0112) // WM_SYSCOMMAND
{
if ((uint)message.WParam == 0xF030) // SC_MAXIMIZE
{
// the window was maximized
}
}
base.WndProc(ref message);
}
I believe hooking the foreign window's WndProc will be the way to go. However, I also believe I can use SetWindowsHookEx or SetWinEventHook from user32 to also achieve this. I currently am already using SetWinEventHook to capture the hWnd of a window when it becomes focused. I tried to use SetWindowsHookEx to do the same, but it seemed to be really hard to do in C#, so I went with SetWinEventHook instead.
Any help would be appreciated.
lowpro S7 Pro
Edit: there is some more information in this post.
Last edited: