Drawing problems!
Hello,
I was wondering if anyone has a solution to keep something drawn on my screen, I have kind of fixed it by just putting a Timer in my code and getting it to draw the image over and over but this causes lag and is a bit of a problem!
If i don't do that to keep the image on the screen, the image will show but as soon as something refreshes behind it the drawn image will be gone!
Is there anyway to keep the image drawn on the screen by not using a timer just to repeat the drawing process ?
Here is my whole code if this helps:
Thanks in advance guys 
I was wondering if anyone has a solution to keep something drawn on my screen, I have kind of fixed it by just putting a Timer in my code and getting it to draw the image over and over but this causes lag and is a bit of a problem!
If i don't do that to keep the image on the screen, the image will show but as soon as something refreshes behind it the drawn image will be gone!
Is there anyway to keep the image drawn on the screen by not using a timer just to repeat the drawing process ?
Here is my whole code if this helps:
Code:
Public Class Form1
Declare Function GetDC Lib "user32.dll" (ByVal hWnd As IntPtr) As System.IntPtr
Declare Function ReleaseDC Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal hdc As IntPtr) As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim width As String = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString
Dim height As String = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString
Label1.Text = width
Label2.Text = height
Dim width2 As Integer = CInt(Label1.Text.ToString)
Dim height2 As Integer = CInt(Label2.Text.ToString)
Label1.Text = CStr(width2 / 2)
Label2.Text = CStr(height2 / 2)
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim width3 As Integer = Label1.Text
Dim height3 As Integer = Label2.Text
Dim hdc As IntPtr = GetDC(IntPtr.Zero)
Dim gr As Graphics = Graphics.FromHdc(hdc)
Dim Point As New Point(width3, height3)
If RadioButton1.Checked = True Then
gr.DrawImage(My.Resources.cross1, Point)
ElseIf RadioButton2.Checked = True Then
gr.DrawImage(My.Resources.cross2, Point)
ElseIf RadioButton3.Checked = True Then
gr.DrawImage(My.Resources.cross3, Point)
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
If RadioButton1.Checked = True Then
PictureBox1.Image = My.Resources.cross1
End If
If RadioButton2.Checked = True Then
PictureBox1.Image = My.Resources.cross2
ElseIf radiobutton3.checked = True Then
PictureBox1.Image = My.Resources.cross3
End If
End Sub
End Class
