drag - Flicker on DragMove of Border-less WPF Custom Window -
i have custom, border-less window intended act base form future wpf projects. i've managed simulate near of native window behaviours, i'm having problem dragmove. wanted window reposition above task bar when user drags title bar behind windows task bar, whole window visible. managed overriding onlocationchanged method, because mouse related handlers blocked during dragmove.
this works charm, except flicker when dragging title bar along windows task bar. can see trying redraw window have been, down below, , redraws window again in intended place.
how can interrupt redrawing properly? many thanks!
this, this, this , this question did not me @ all, unfortunately. here extract of code:
protected override void onlocationchanged(eventargs e) { base.onlocationchanged(e); var activescreenheight = system.windows.forms.screen.fromhandle(new windowinterophelper(this).handle).workingarea.bottom - toolbarsnapthreshold; if (activescreenheight < this.restorebounds.top) { this.top = activescreenheight - this.restorebounds.height + toolbarsnapthreshold; } } protected void maximizeorrestore() { this.windowstate = (this.windowstate == windowstate.normal) ? windowstate.maximized : windowstate.normal; this.lastnonminimizedstate = this.windowstate; } protected void restoreanddragmove(mousebuttonstate leftmousebuttonstate) { if (leftmousebuttonstate == mousebuttonstate.pressed) { if (this.windowstate == windowstate.maximized) { var activescreenwidth = system.windows.forms.screen.fromhandle(new windowinterophelper(this).handle).bounds.width; var windowcurrentwidth = this.restorebounds.width; var windowpositionadjustx = this.relativemousepositionx - (windowcurrentwidth / 2); if (windowpositionadjustx < 0) { windowpositionadjustx = 0; } else if (windowpositionadjustx + windowcurrentwidth > activescreenwidth) { windowpositionadjustx = activescreenwidth - windowcurrentwidth; } this.windowstate = windowstate.normal; this.lastnonminimizedstate = this.windowstate; this.left = windowpositionadjustx - this.relativemousepositionx + this.originalmousepositionx; this.top = 0 - this.relativemousepositiony + this.originalmousepositiony; } this.dragmove(); } } private void window_titlebarclicked(object sender, mousebuttoneventargs e) { if (e.leftbutton == mousebuttonstate.pressed) { this.relativemousepositionx = e.getposition(this).x; this.relativemousepositiony = e.getposition(this).y; this.originalmousepositionx = system.windows.forms.cursor.position.x; this.originalmousepositiony = system.windows.forms.cursor.position.y; if (e.clickcount == 2) { this.maximizeorrestore(); } } }
Comments
Post a Comment