Zaklady: Jak zakreslit do ovladaciho prvku pomoci GDI

Komentare jsou sice v AJ, ale naprosto srozumitelne:

//Tyto atributy zde nemusi byt, funguje to stejne dobre i bez nich
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)]
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    // Get handle to device context.
    IntPtr hdc = e.Graphics.GetHdc();
    // Create new graphics object using handle to device context.
    Graphics newGraphics = Graphics.FromHdc(hdc);
    // Draw rectangle to screen.
    newGraphics.DrawRectangle(new Pen(Color.Red, 3), 0, 0, 200, 100);
    // Release handle to device context and dispose of the Graphics object
    e.Graphics.ReleaseHdc(hdc);
    newGraphics.Dispose();
}

Snad si nekdy udelam cas a tento clanek rozsirim aby vas naucil jak delat vyrezy obrazovky s pohledem na to co vyrezavate.

Leave a Reply