Solved

GDI+ Question

Posted on 2004-10-11
3
218 Views
Last Modified: 2010-04-23
Does anyone know how to draw on the desktop?  Not on a form.  Let's say for example, how would you draw the following line?

Start the line at the form's left edge (y-axis doesn't matter) and draw the line to the left (in other words, off the form and across the desktop).

Please help.

Thanks in advance.
0
Comment
Question by:jrandallsexton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 500 total points
ID: 12286581
Hi jrandallsexton,

You could try one of these things,

1. With API

Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As IntPtr) As IntPtr
        Dim deskDC As IntPtr = GetDC(IntPtr.Zero)
        Dim g As Graphics = Graphics.FromHdc(deskDC)
        g.DrawLine(New Pen(Color.Black), 0, 0, 300, 300)

2. With the Controlpaint class

        Dim p1 As New Point(0, 0)
        Dim p2 As New Point(300, 300)
        ControlPaint.DrawReversibleLine(p1, p2, Color.Black)

0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12286603
I haven't tried #1 but #2 works.  I've never heard of ControlPaint.  I'm going to do some reading (a lot actually) on that.

I think you've pointed me in exactly the direction I needed.  Thanks.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12286688
Hi Jrandallsexton,

Its a very cool class you can draw entire datagrids with that, if you combine method 1 and 2, you can even do that on the desktop.

Sorry I forgot one thing for the first method don't forget to release the dc aswell, otherwise you will run out of memory.

Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Long, ByVal hdc As Long) As intptr
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question