Resizer - YiZhang-Paul/Mock_Up_Calculator GitHub Wiki
Namespace: UserControlClassLibrary
Implements: IResize
Description: Allows border-less forms to be resized with mouse drag.
Constructors | Usage |
---|---|
Resizer(Form, int) | Initializes an instance of Resizer class |
Properties | Usage |
---|---|
Keys<int[]> | return code for WM_NCHITTEST message |
Boxes<Dictionary<int, Func<Rectangle>>> | get rectangle area that captures mouse pointer |
Examples:
protected override void WndProc(ref Message message) {
base.WndProc(ref message);
//WM_NCHITTEST
if(message.Msg == 0x84) {
var resizer = new Resizer(this, 10); //"this" stands for parent form
foreach(int key in resizer.Keys) {
if(resizer.Boxes[key]().Contains(PointToClient(Cursor.Position))) { //get cursor position
message.Result = (IntPtr)key;
break;
}
}
}
}
Remarks:
This class intercepts WndProc() message and checks if mouse cursor is pointing at any border area of main application window - if mouse pointer is detected, corresponding WM_NCHITTEST return code will be attached to message result, allowing border-less forms to be resized.