Author | Message | Time |
---|---|---|
Spilled[DW] | How would I Catch a Resize event? Would I Use WM_SIZE? If so how would I determine if the form is resized because aint this used for catching Minimize and Maximize events? | February 10, 2006, 6:51 PM |
Myndfyr | I knew this would come in handy for more than skinning one day! [code] case WM.WM_SYSCOMMAND: if (m.WParam == (IntPtr)SystemCommands.Maximize || m.WParam == (IntPtr)SystemCommands.MaximizeByFrame) { OnMaximized(); } else if (m.WParam == (IntPtr)SystemCommands.Restore || m.WParam == (IntPtr)SystemCommands.RestoreByFrame) { OnRestored(); } else if (m.WParam == (IntPtr)SystemCommands.Minimize) { OnMinimized(); } DefWndProc(ref m); break; #endregion [/code] m is the Msg struct (this is C# btw, so I wouldn't try to stick this into your code directly), but look up WM_SYSCOMMAND in MSDN to find out what the command constants are (I wouldn't be surprised if it was SC_MAXIMIZE/SC_MINIMIZE). WM_SIZE does other resize events though. | February 10, 2006, 9:51 PM |
Spilled[DW] | Thanks once again Myndfyre, appreciate it! | February 10, 2006, 11:29 PM |
Skywing | I think looking at WM_SYSCOMMAND for that purpose is wrong and might not work properly for things programmatically minimizing or maximizing a window. It would probably be better to use WM_WINDOWPOSCHANGED, or if you are passing that to DefWindowProc, WM_SIZE. If you are using WM_WINDOWPOSCHANGED, you will have to figure out what operation is happening based on the old and new window positions. If you are using WM_SIZE, wParam indicates what sort of operation just occured. You should use GetClientRect in WM_SIZE to determine the new client area instead of relying on the truncated values provided in lParam. | February 11, 2006, 12:51 PM |
Myndfyr | [quote author=Skywing link=topic=14218.msg145534#msg145534 date=1139662307] I think looking at WM_SYSCOMMAND for that purpose is wrong and might not work properly for things programmatically minimizing or maximizing a window. It would probably be better to use WM_WINDOWPOSCHANGED, or if you are passing that to DefWindowProc, WM_SIZE. If you are using WM_WINDOWPOSCHANGED, you will have to figure out what operation is happening based on the old and new window positions. If you are using WM_SIZE, wParam indicates what sort of operation just occured. You should use GetClientRect in WM_SIZE to determine the new client area instead of relying on the truncated values provided in lParam. [/quote] Ahh, so WM_SIZE does work? I couldn't ever get this to function. But -- C#. :) | February 12, 2006, 12:49 AM |
Skywing | [quote author=MyndFyre link=topic=14218.msg145619#msg145619 date=1139705352] Ahh, so WM_SIZE does work? I couldn't ever get this to function. But -- C#. :) [/quote] I suspect that you (or something else) is handling WM_WINDOWPOSCHANGED and not passing it to DefWindowProc. WM_SIZE/WM_MOVE are compatibility messages sent to programs that don't support figuring out their new positioning from the newer WM_WINDOWPOSCHANGED. If the program handles WM_WINDOWPOSCHANGED internally, WM_SIZE/WM_MOVE would not be sent as they are generated by DefWindowProc in response to WM_WINDOWPOSCHANGED. You can use them in new programs if you don't want to write code to determine your new positioning from WM_WINDOWPOSCHANGED, however. This requires that you pass WM_WINDOWPOSCHANGED to DefWindowProc, though. | February 12, 2006, 5:01 PM |