GDI+ error with remote desktop minimized

C

cgreenfield

I have a problem with GDI+ when using a remote desktop that gets
minimized. I need to use:

Me.CreateGraphics to get a graphics object and then draw on it. If
this happens when the remote desktop is minimized I get the following
error:

A generic error occurred in GDI+.
at System.Drawing.Graphics.Clear(Color color)

I have written a test project in VB.NET, listing given below:

Public Class Form1


Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Timer1.Start()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Const waitfor As Integer = 10
Static nsecs As Integer
nsecs += 1
txtProgress.Text = "Report will be written in " + (waitfor -
nsecs).ToString + " seconds"
Application.DoEvents()
If nsecs = waitfor Then
nsecs = 0
Timer1.Stop()
Timer1.Enabled = False

Dim myGraphics As Drawing.Graphics = Me.CreateGraphics
myGraphics.Clear(Color.White)

txtProgress.Text = "Finished"

End If
End Sub
End Class

The code runs fine if the remote desktop is kept open.

There is a similar post to this at:

http://groups.google.co.uk/group/mi...+minimized+gdi&rnum=10&hl=en#66da52e64cff6514


However, I need to know if there is a way round this. I need to get a
graphics object and can't depend on the user not minimising the remote
desktop.

Any help appreciated.

Claire
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top