c# - Resizing Windows Forms -
i have form it's formborderstyle set sizable. creates grip in bottom right. way resize window mouse right on edge. i'm wondering if there way change cursor able resize when user mouses on grip, or if can increase range @ allow resize on edge don't have precise mouse location.
here link similar question. guy has no borders, may have little differently, should give direction go in. repaste code here completion:
public partial class form1 : form { public form1() { initializecomponent(); this.formborderstyle = formborderstyle.none; this.doublebuffered = true; this.setstyle(controlstyles.resizeredraw, true); } private const int cgrip = 16; // grip size private const int ccaption = 32; // caption bar height; protected override void onpaint(painteventargs e) { rectangle rc = new rectangle(this.clientsize.width - cgrip, this.clientsize.height - cgrip, cgrip, cgrip); controlpaint.drawsizegrip(e.graphics, this.backcolor, rc); rc = new rectangle(0, 0, this.clientsize.width, ccaption); e.graphics.fillrectangle(brushes.darkblue, rc); } protected override void wndproc(ref message m) { if (m.msg == 0x84) { // trap wm_nchittest point pos = new point(m.lparam.toint32() & 0xffff, m.lparam.toint32() >> 16); pos = this.pointtoclient(pos); if (pos.y < ccaption) { m.result = (intptr)2; // htcaption return; } if (pos.x >= this.clientsize.width - cgrip && pos.y >= this.clientsize.height - cgrip) { m.result = (intptr)17; // htbottomright return; } } base.wndproc(ref m); } }
Comments
Post a Comment