Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to refresh or repaint the desktop(screen)?

Status
Not open for further replies.

Giraffe69

Programmer
Oct 7, 2003
22
GB
How do I get the desktop to refresh?

I've drawn some graphics on the screen by doing:

Code:
        Using gr As Graphics = Graphics.FromHwnd(GetDesktopWindow())
            gr.DrawString("text", New Font("Arial", 20), Brushes.Green, New Point(50, 100))
            gr.DrawImage(New Bitmap("c:\logo.bmp"), New Point(800, 100))
        End Using

Later, I want to remove them. I've tried different ways, like:

Code:
        SendMessage(GetDesktopWindow, WM_PAINT, 0, 0)

and:

Code:
        Invalidate(Screen.PrimaryScreen.WorkingArea, True)

and Clearing or Restoring the Graphics, all without success.
This feels like something that should be really simple!
Any help would be really appreciated?!

"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Robert Wilensky
 

I think you need to use the same Graphics object that you used to draw the graphics:

Dim gr As Graphics
Graphics.FromHwnd(GetDesktopWindow()

Using gr
gr.DrawString("text", New Font("Arial", 20), Brushes.Green, New Point(50, 100))
gr.DrawImage(New Bitmap("c:\logo.bmp"), New Point(800, 100))
End Using


Then:

gr.Clear()

to remove the drawing.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top