Constrain form to horizontal resize only?
-
Can anyone suggest the best way to constrain a form to horizontal resizing only? Delegating a Resize handler doesn't work so great. If I set Height=400; in the Resize handler, it does indeed force the window to a height of 400 (or whatever you like) but when the user drags the window border, the window momentarily resizes to fit the mouse, and then the handler kicks in and pushes it back to 400 and back and forth causes a nasty flicker. I've seen some Win32 examples that process WM_NCHITTEST messages and return 0; but I don't see a way to do this with C# .NET Framework. Any ideas? -- James --
-
Can anyone suggest the best way to constrain a form to horizontal resizing only? Delegating a Resize handler doesn't work so great. If I set Height=400; in the Resize handler, it does indeed force the window to a height of 400 (or whatever you like) but when the user drags the window border, the window momentarily resizes to fit the mouse, and then the handler kicks in and pushes it back to 400 and back and forth causes a nasty flicker. I've seen some Win32 examples that process WM_NCHITTEST messages and return 0; but I don't see a way to do this with C# .NET Framework. Any ideas? -- James --
Have you looked at the MinimumSize/MaximumSize properties? You can also check for the WM_GETMINMAXINFO message.
α.γεεκ
Fortune passes everywhere.
Duke Leto Atreides -
Can anyone suggest the best way to constrain a form to horizontal resizing only? Delegating a Resize handler doesn't work so great. If I set Height=400; in the Resize handler, it does indeed force the window to a height of 400 (or whatever you like) but when the user drags the window border, the window momentarily resizes to fit the mouse, and then the handler kicks in and pushes it back to 400 and back and forth causes a nasty flicker. I've seen some Win32 examples that process WM_NCHITTEST messages and return 0; but I don't see a way to do this with C# .NET Framework. Any ideas? -- James --
-
set the maximumsize.Height and minimumsize.Height Form properties to 400. The user will not be able to resize the form vertically (less than 400).