[HELP] Draw direct to screen.
Well I'm stuck,
I've been googling. experimenting, inventing and nothing has worked so far.
What I'm attempting to do, is draw directly to screen display. I get the feeling this could be impossible so my first question is, "Is this possible or not?". If so, my second question is "How?"
I've been trying for a while, attempting to create a device context for the screen display. But I don't know if this is even the right approach to go for. Here's what I've been working with atm.
[php]
Imports System.Runtime****teropServices
Public Class Form1
Dim ScreenDC As IntPtr
<DllImport("Gdi32.dll")> _
Public Shared Function CreateDC(ByVal driverName As String, ByVal deviceName As String, ByVal output As String, ByVal lpInitData As IntPtr) As IntPtr
End Function
<DllImport("Gdi32.dll")> _
Public Shared Function DeleteDC(ByVal dc As IntPtr) As Boolean
End Function
Dim sWidth = Screen.PrimaryScreen.Bounds.Width
Dim sHeight = Screen.PrimaryScreen.Bounds.Height
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ScreenDC = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))
Dim mg As Graphics = Graphics.FromHdc(ScreenDC)
Dim rPen As New Pen(Color.Red, 1)
mg.DrawLine(rPen, sWidth, (sHeight - 25), sWidth, (sHeight + 25))
mg.DrawLine(rPen, (sWidth - 25), sHeight, (sWidth + 25), sHeight)
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
DeleteDC(ScreenDC)
End Sub
End Class
[/php]
I've been trying to adapt snippets i've used for various other projects I've made over time and somehow get this to work. (i.e the ScreenDC was something I used for a ScreenScanner a while back)
At the moment I'm trying to draw pretty much a crosshair on the screen, nothing happens however when I press Button1. I wasn't fully expecting this code to work, but I'm out of ideas.
Anyone got an idea of how to go about this?
Cheers,
J-Deezy.
I've been googling. experimenting, inventing and nothing has worked so far.
What I'm attempting to do, is draw directly to screen display. I get the feeling this could be impossible so my first question is, "Is this possible or not?". If so, my second question is "How?"
I've been trying for a while, attempting to create a device context for the screen display. But I don't know if this is even the right approach to go for. Here's what I've been working with atm.
[php]
Imports System.Runtime****teropServices
Public Class Form1
Dim ScreenDC As IntPtr
<DllImport("Gdi32.dll")> _
Public Shared Function CreateDC(ByVal driverName As String, ByVal deviceName As String, ByVal output As String, ByVal lpInitData As IntPtr) As IntPtr
End Function
<DllImport("Gdi32.dll")> _
Public Shared Function DeleteDC(ByVal dc As IntPtr) As Boolean
End Function
Dim sWidth = Screen.PrimaryScreen.Bounds.Width
Dim sHeight = Screen.PrimaryScreen.Bounds.Height
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ScreenDC = CreateDC("DISPLAY", Nothing, Nothing, CType(Nothing, IntPtr))
Dim mg As Graphics = Graphics.FromHdc(ScreenDC)
Dim rPen As New Pen(Color.Red, 1)
mg.DrawLine(rPen, sWidth, (sHeight - 25), sWidth, (sHeight + 25))
mg.DrawLine(rPen, (sWidth - 25), sHeight, (sWidth + 25), sHeight)
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
DeleteDC(ScreenDC)
End Sub
End Class
[/php]
I've been trying to adapt snippets i've used for various other projects I've made over time and somehow get this to work. (i.e the ScreenDC was something I used for a ScreenScanner a while back)
At the moment I'm trying to draw pretty much a crosshair on the screen, nothing happens however when I press Button1. I wasn't fully expecting this code to work, but I'm out of ideas.
Anyone got an idea of how to go about this?
Cheers,
J-Deezy.

just an idea

