Click here to Skip to main content
15,887,936 members
Articles / Programming Languages / Visual Basic
Tip/Trick

Draw to Screen without using API

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
25 Jun 2011CPOL 13.7K   1  
Draw to Screen without using API
I like GDI+ very much and today I was playing with some code and luckily I found out how to draw to my computer screen without using any API support.

Hope the code may help someone ....

VB
Public Class Form1
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
        Dim rect As Rectangle = New Rectangle(0, 0, 100, 100)
        Rect.Inflate(2, 2)
        Using g As Graphics = Graphics.FromHwnd(IntPtr.Zero)
            Using lgb As New Drawing2D.LinearGradientBrush(rect, Color.Red, Color.Orange, 90, True)
                g.FillRectangle(lgb, rect)
                g.DrawString(Me.Text, Me.Font, Brushes.White, rect)
            End Using
        End Using
    End Sub
End Class

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Egypt Egypt
Oil & Gas Engineer
C# & VB.net
Coding For Fun Only

Comments and Discussions

 
-- There are no messages in this forum --