Click here to Skip to main content
16,006,440 members
Home / Discussions / C#
   

C#

 
GeneralPixel colors found using GDI+ are different!!!!! Pin
abcxyz8231-Dec-04 22:50
abcxyz8231-Dec-04 22:50 
GeneralRe: Pixel colors found using GDI+ are different!!!!! Pin
Heath Stewart31-Dec-04 23:02
protectorHeath Stewart31-Dec-04 23:02 
GeneralUsing "using" Pin
Identity Undisclosed31-Dec-04 20:50
Identity Undisclosed31-Dec-04 20:50 
GeneralRe: Using "using" Pin
Adam Goossens31-Dec-04 22:11
Adam Goossens31-Dec-04 22:11 
GeneralRe: Using "using" Pin
Heath Stewart31-Dec-04 22:56
protectorHeath Stewart31-Dec-04 22:56 
GeneralRe: Using "using" Pin
Adam Goossens31-Dec-04 23:21
Adam Goossens31-Dec-04 23:21 
GeneralRe: Using "using" Pin
Heath Stewart1-Jan-05 6:29
protectorHeath Stewart1-Jan-05 6:29 
GeneralRe: Using "using" Pin
Heath Stewart31-Dec-04 23:07
protectorHeath Stewart31-Dec-04 23:07 
You generally do not dispose objects you didn't create. This includes the PaintEventArgs.Graphics property. Whether you override OnPaint (best for owner drawing when extending a control, including Forms) or handle the Paint event on another control, the default Control implementation will create a Graphics object from the HDC (handle to a device context, which is what Windows uses to paint to various devices like your monitor, a printer, etc.). When OnPaint returns and any event handlers are finished, the object will be disposed.

You should, for example, dispose a Graphics object when you've created one from a Bitmap or other Image using Graphics.FromImage. You should also dispose the Graphics object returned from Control.CreateGraphics.

If you dispose of the Graphics too early you may find that the control isn't painted properly or that an exception is thrown, most likely from a native AV (access violation) exception being thrown.

So, again, as a general rule don't dispose what you didn't create.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
Generaluse shellexecute to create an email Pin
TNL31-Dec-04 18:14
TNL31-Dec-04 18:14 
GeneralRe: use shellexecute to create an email Pin
Heath Stewart31-Dec-04 22:53
protectorHeath Stewart31-Dec-04 22:53 
GeneralRe: use shellexecute to create an email Pin
TNL31-Dec-04 23:48
TNL31-Dec-04 23:48 
GeneralRe: use shellexecute to create an email Pin
Heath Stewart1-Jan-05 6:33
protectorHeath Stewart1-Jan-05 6:33 
Generalbits Pin
Tyrus18231-Dec-04 16:37
Tyrus18231-Dec-04 16:37 
GeneralRe: bits Pin
Heath Stewart31-Dec-04 22:58
protectorHeath Stewart31-Dec-04 22:58 
GeneralSIMPLE SIMPLE QUESTION Pin
...---...31-Dec-04 9:44
...---...31-Dec-04 9:44 
GeneralRe: SIMPLE SIMPLE QUESTION Pin
SimonS31-Dec-04 10:29
SimonS31-Dec-04 10:29 
GeneralRe: SIMPLE SIMPLE QUESTION Pin
Heath Stewart31-Dec-04 10:46
protectorHeath Stewart31-Dec-04 10:46 
GeneralRe: SIMPLE SIMPLE QUESTION Pin
...---...31-Dec-04 10:50
...---...31-Dec-04 10:50 
GeneralRe: SIMPLE SIMPLE QUESTION Pin
Heath Stewart31-Dec-04 11:06
protectorHeath Stewart31-Dec-04 11:06 
GeneralRe: SIMPLE SIMPLE QUESTION Pin
SimonS31-Dec-04 11:39
SimonS31-Dec-04 11:39 
GeneralRe: SIMPLE SIMPLE QUESTION Pin
Heath Stewart31-Dec-04 12:22
protectorHeath Stewart31-Dec-04 12:22 
GeneralALMOST WORKS! BUT.... Pin
...---...31-Dec-04 15:39
...---...31-Dec-04 15:39 
GeneralRe: ALMOST WORKS! BUT.... Pin
Matt Gerrans3-Jan-05 8:43
Matt Gerrans3-Jan-05 8:43 
GeneralCPU Usage and thread problem Pin
aswanee31-Dec-04 9:37
aswanee31-Dec-04 9:37 
GeneralRe: CPU Usage and thread problem Pin
leppie31-Dec-04 10:23
leppie31-Dec-04 10:23 

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.