Click here to Skip to main content
15,912,285 members
Home / Discussions / C#
   

C#

 
GeneralRe: re Code Pin
Thomas Weller29-Nov-08 17:57
Thomas Weller29-Nov-08 17:57 
GeneralRe: re Code Pin
Christian Graus29-Nov-08 18:13
protectorChristian Graus29-Nov-08 18:13 
GeneralRe: re Code Pin
Thomas Weller29-Nov-08 18:24
Thomas Weller29-Nov-08 18:24 
AnswerRe: re Code Pin
Thomas Weller29-Nov-08 18:07
Thomas Weller29-Nov-08 18:07 
GeneralRe: re Code Pin
Paul Conrad30-Nov-08 6:29
professionalPaul Conrad30-Nov-08 6:29 
AnswerRe: re Code Pin
MickCurley30-Nov-08 0:34
MickCurley30-Nov-08 0:34 
QuestionA problem with System.Drawing.Drawing2D Pin
Pedram Behroozi29-Nov-08 9:48
Pedram Behroozi29-Nov-08 9:48 
GeneralRe: A problem with System.Drawing.Drawing2D Pin
Luc Pattyn29-Nov-08 10:46
sitebuilderLuc Pattyn29-Nov-08 10:46 
Hi,

1.
yes all painting should be performed in Paint handlers; one of the reasons is exactly the problem you encounter: it is the Paint handlers that will get fired by Windows when ever there is reason to repaint (part of) a Control (a Form is a Control); restoring from Minimized is a very good reason to repaint everything.

2.
Graphics.FromHwnd() creates a NEW Graphics, which you must Dispose() off when you are done. It is a slow and costly operation that can be avoided.

3.
Why take the long route of taking a handle, asking for a new Graphics, then drawing; all you have to do is set up some data fields that describe the rectangle you want, then Invalidate() the Control (in your case PictureBox), so its Paint handler gets executed again (and draws a rectangle according to the relevant data fields). The Graphics you find in the PaintEventArgs is free, it is not expensive, and you SHOULD NOT Dispose() of that one, since you did not cause its creation, so it isn't your Graphics object.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Fixturized forever. Confused | :confused:


GeneralRe: A problem with System.Drawing.Drawing2D Pin
Guffa29-Nov-08 20:44
Guffa29-Nov-08 20:44 
GeneralRe: A problem with System.Drawing.Drawing2D Pin
Pedram Behroozi30-Nov-08 8:29
Pedram Behroozi30-Nov-08 8:29 
GeneralRe: A problem with System.Drawing.Drawing2D Pin
Guffa30-Nov-08 9:10
Guffa30-Nov-08 9:10 
GeneralRe: A problem with System.Drawing.Drawing2D Pin
Pedram Behroozi30-Nov-08 9:49
Pedram Behroozi30-Nov-08 9:49 
QuestionGraphics ? Pin
nlowdon29-Nov-08 8:49
nlowdon29-Nov-08 8:49 
AnswerRe: Graphics ? Pin
Christian Graus29-Nov-08 13:47
protectorChristian Graus29-Nov-08 13:47 
GeneralRe: Graphics ? Pin
electriac30-Nov-08 6:44
electriac30-Nov-08 6:44 
QuestionHow can I implement this complex object Pin
mbudak29-Nov-08 1:16
mbudak29-Nov-08 1:16 
AnswerRe: How can I implement this complex object Pin
Chris Copeland29-Nov-08 3:19
mveChris Copeland29-Nov-08 3:19 
AnswerRe: How can I implement this complex object Pin
Dag Oystein Johansen29-Nov-08 4:08
Dag Oystein Johansen29-Nov-08 4:08 
AnswerRe: How can I implement this complex object Pin
Dominic Goulet1-Dec-08 1:00
Dominic Goulet1-Dec-08 1:00 
Questionaddin to IE Pin
Maverickcool29-Nov-08 1:06
Maverickcool29-Nov-08 1:06 
Questionassembly won't run from network folder. Pin
swjam29-Nov-08 0:23
swjam29-Nov-08 0:23 
AnswerRe: assembly won't run from network folder. Pin
Wendelius29-Nov-08 0:32
mentorWendelius29-Nov-08 0:32 
AnswerRe: assembly won't run from network folder. Pin
User 665829-Nov-08 0:37
User 665829-Nov-08 0:37 
AnswerRe: assembly won't run from network folder. Pin
Dave Kreskowiak29-Nov-08 5:01
mveDave Kreskowiak29-Nov-08 5:01 
QuestionScreen Capture Pin
krinaljariwala28-Nov-08 23:49
krinaljariwala28-Nov-08 23:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.