Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Can anybody tell me what's wrong with my code here? I try to draw a rectangle on my desktop.

 

 

 

 

 

Public Class Win32

Public Declare Function GetDC Lib "user32" (ByVal hwnd As Integer) As Integer

Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

Public Declare Function GetDesktopWindow Lib "user32" () As Integer

 

End Class

 

 

Sub Main()

Dim rWorkArea As Rectangle

Dim m_graph As Graphics

Dim hwnd As Integer

Dim m_lHwnd As Long

Dim m_lHdc As Integer

 

hwnd = Win32.GetDesktopWindow

m_lHdc = Win32.GetDC(hwnd)

rWorkArea = Screen.GetWorkingArea(Screen.PrimaryScreen.WorkingArea)

 

Dim hdc As IntPtr

hdc = IntPtr.op_Explicit(m_lHdc)

m_graph = Graphics.FromHdc(hdc)

 

Dim redPen As New Pen(Color.Red, 4)

' Draw rectangle with GDI+.

m_graph.DrawRectangle(redPen, rWorkArea)

 

'm_graph.ReleaseHdc(hdc)

Win32.ReleaseDC(hwnd, m_lHdc)

end sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...