vb.net - resize borderless form -
i able resize using code below resizes towards right side , bottom right corner
i want modify code user can re size form bottom left corner.
also of solution given on site based on wndproc / wm_nclbuttondown , not using because form have lots of controls flicker's badly.
private shared frmlastwidth integer = 0 private shared frmlastheight integer = 0 private shared frmwidth integer private shared frmheight integer private shared frmisresizing boolean = false private frmrectangle new system.drawing.rectangle() private sub resizeme_mouseup(byval sender object, byval e system.windows.forms.mouseeventargs) handles resizeme.mouseup if frmisresizing frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmwidth, frmheight) controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) me.width = frmwidth me.height = frmheight frmisresizing = false end if end sub private sub resizeme_mousedown(byval sender object, byval e system.windows.forms.mouseeventargs) handles resizeme.mousedown frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmwidth, frmheight) controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) end sub private sub resizeme_mousemove(byval sender object, byval e system.windows.forms.mouseeventargs) handles resizeme.mousemove if e.button = windows.forms.mousebuttons.left 'me.resizeredraw = false dim sizeagex integer = mouseposition.x - me.location.x dim sizeagey integer = mouseposition.y - me.location.y ' use restrict width if sizeagex < me.minimumsize.width sizeagex = me.minimumsize.width end if ' use restrict height if sizeagey < me.minimumsize.height sizeagey = me.minimumsize.height end if frmwidth = sizeagex frmheight = sizeagey if frmlastwidth = 0 frmlastwidth = frmwidth end if if frmlastheight = 0 frmlastheight = frmheight end if if frmisresizing frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmlastwidth, frmlastheight) end if frmisresizing = true controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) frmlastwidth = frmwidth frmlastheight = frmheight frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmwidth, frmheight) controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) end sub private sub resizeright(byval e system.windows.forms.mouseeventargs) 'me.resizeredraw = false dim sizeagex integer = (mouseposition.x + me.width) - me.location.x dim sizeagey integer = (mouseposition.y + me.height) - me.location.y ' use restrict width if sizeagex < me.minimumsize.width sizeagex = me.minimumsize.width end if ' use restrict height if sizeagey < me.minimumsize.height sizeagey = me.minimumsize.height end if frmwidth = sizeagex frmheight = sizeagey if frmlastwidth = 0 frmlastwidth = frmwidth end if if frmlastheight = 0 frmlastheight = frmheight end if if frmisresizing frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmlastwidth, frmlastheight) end if frmisresizing = true controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) frmlastwidth = frmwidth frmlastheight = frmheight frmrectangle.location = new system.drawing.point(me.left, me.top) frmrectangle.size = new system.drawing.size(frmwidth, frmheight) controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) end if end sub
update
i able re size form bottom left corner shows dashed lines many times dashed lines not restrict minimum height , width of form modified code is
private sub resizeright(byval e system.windows.forms.mouseeventargs) 'me.resizeredraw = false dim sizeagex integer = mouseposition.x + me.location.x dim sizeagey integer = mouseposition.y + me.location.y ' use restrict width if sizeagex > me.minimumsize.width sizeagex = me.minimumsize.width end if ' use restrict height if sizeagey > me.minimumsize.height sizeagey = me.minimumsize.height end if frmwidth = sizeagex - e.x frmheight = sizeagey - e.y if frmlastwidth = 0 frmlastwidth = frmwidth end if if frmlastheight = 0 frmlastheight = frmheight end if if frmisresizing frmrectangle.location = new system.drawing.point(me.left + e.x, me.top) frmrectangle.size = new system.drawing.size(frmlastwidth, frmlastheight) end if frmisresizing = true controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) frmlastwidth = frmwidth frmlastheight = frmheight frmrectangle.location = new system.drawing.point(me.left + e.x, me.top) frmrectangle.size = new system.drawing.size(frmwidth, frmheight) controlpaint.drawreversibleframe(frmrectangle, color.black, system.windows.forms.framestyle.dashed) end sub
what suspend control layout (suspend.layout) according http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout%28vs.80%29.aspx might able stop flickering.
Comments
Post a Comment