cheng_sh Posted May 26, 2003 Posted May 26, 2003 Hello everybody, Is it possible to use VB.NET to draw a Rectangle on top of the screen/desktop? Can somebody teach me how to do that? Thank you very much. Quote
cheng_sh Posted May 26, 2003 Author Posted May 26, 2003 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 Quote
*Experts* mutant Posted May 27, 2003 *Experts* Posted May 27, 2003 What errors are you getting? Quote
cheng_sh Posted May 27, 2003 Author Posted May 27, 2003 No error but just can't see the rectangle that's suppose to be on top of the desktop. Thank you for your reply. Quote
cheng_sh Posted May 28, 2003 Author Posted May 28, 2003 Can somebody kindly teach me about this? Thank you very much. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.