Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.NET Custom Control (custom drawing) Refresh issue
    primarykey
    data
    text
    <p>I've created a simple solution with 2 projects. The 1st project (class library) contains a custom control called Container which draws itself with rounded corners. The 2nd project (windows forms) is a test application.</p> <p>If I add a Container instance to main Form in the 2nd project it shows the rounded corners nicely. Also when I run the 2nd project I can see the Container.</p> <p>However when I start moving the form (click and hold the title bar), especially when I move it very fast, all the drawing is messed up, drawn over and over again but not clearing it's surface first...</p> <p>I can call Container1.Refresh() in the Form1.Move event, but I don't want to set this every time because this also means I have to call Container1.Refresh() in the <code>Form1.Resize</code> event and who knows which other event...</p> <p>Is there an event in the Container (control) class itself where I should call Me.Refresh() or Me.Update() or Me.Invalidate() ?</p> <p>For reference (Form1.vb)</p> <pre><code>Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move Me.Container1.Refresh() End Sub End Class </code></pre> <p>for reference (Container.vb):</p> <pre><code>Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D Public Class Container : Inherits Control Private _Gp As GraphicsPath Private Sub Container_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim r As Rectangle = e.ClipRectangle Dim gp As New GraphicsPath Dim cs As Integer = 25 'CornerSize' r.Inflate(-5, -5) gp.AddArc(r.X, r.Y, cs, cs, 180, 90) gp.AddArc(r.X + r.Width - cs, r.Y, cs, cs, 270, 90) gp.AddArc(r.X + r.Width - cs, r.Y + r.Height - cs, cs, cs, 0, 90) gp.AddArc(r.X, r.Y + r.Height - cs, cs, cs, 90, 90) Dim t As Single = cs / 2 + r.Y gp.AddLine(r.X, r.Y + r.Height - cs, r.X, t) e.Graphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias e.Graphics.DrawPath(Pens.Black, gp) End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload