c# - How to move and resize a form without a border? -



c# - How to move and resize a form without a border? -

does know how can resize winform when has no border. don't want default border windows has, changed property "formborderstyle" "none". removed border, although can't resized. i've figured out how move form around, need know how resize it.

some sample code allow moving , resizing form:

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); } }

c# winforms resize border formborderstyle

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -