Click here to Skip to main content
15,910,303 members
Home / Discussions / C#
   

C#

 
GeneralRe: Recording my internet browsing on file Pin
Member 83534878-Nov-11 2:13
Member 83534878-Nov-11 2:13 
AnswerRe: Recording my internet browsing on file Pin
BobJanova8-Nov-11 1:19
BobJanova8-Nov-11 1:19 
GeneralRe: Recording my internet browsing on file Pin
Member 83534878-Nov-11 3:55
Member 83534878-Nov-11 3:55 
GeneralRe: Recording my internet browsing on file Pin
BobJanova8-Nov-11 4:16
BobJanova8-Nov-11 4:16 
GeneralRe: Recording my internet browsing on file Pin
Member 83534878-Nov-11 5:04
Member 83534878-Nov-11 5:04 
GeneralRe: Recording my internet browsing on file Pin
BobJanova8-Nov-11 5:19
BobJanova8-Nov-11 5:19 
QuestionWM_NCPAINT and Massive Amount of Flicker Pin
Matt U.7-Nov-11 14:39
Matt U.7-Nov-11 14:39 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
Luc Pattyn7-Nov-11 15:35
sitebuilderLuc Pattyn7-Nov-11 15:35 
Hi,

I see two problems:

1.
the WndProc method is called quite often since Windows sends messages all the time, e.g. when you move the mouse over your form; so you should make it as lightweight as possible. And you didn't: you are creating the graphics object g whether you will use it or not. Now creating a Graphics is expensive, so this is slowing your form down, its responsiveness is not going to be what it could and should be.

2.
The Graphics object, when you created and used it but no longer need it, should be disposed of. So you should add something like if (g!=null) g.Dispose(); or just g.Dispose(); at some appropriate location inside WndProc (I guess just before calling releaseDC would be right, assuming you put FromHdc right in front of OnNcPaint). Failing to do so will enlarge your app's memory footprint and make the job of the garbage collector somewhat larger too.

BTW: this is true for most every instance you create when the class offers a public Dispose() method; the sequence ought to be: create-use-dispose. And the bigger the object, the more reason not to forget this. Note: there is a using statement that often comes in handy here.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: WM_NCPAINT and Massive Amount of Flicker Pin
Matt U.7-Nov-11 15:43
Matt U.7-Nov-11 15:43 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
Luc Pattyn7-Nov-11 16:06
sitebuilderLuc Pattyn7-Nov-11 16:06 
GeneralRe: WM_NCPAINT and Massive Amount of Flicker Pin
Matt U.7-Nov-11 16:25
Matt U.7-Nov-11 16:25 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
Luc Pattyn8-Nov-11 1:38
sitebuilderLuc Pattyn8-Nov-11 1:38 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
J a a n s7-Nov-11 21:52
professionalJ a a n s7-Nov-11 21:52 
QuestionI want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 7:28
zahra19917-Nov-11 7:28 
AnswerMessage Removed Pin
7-Nov-11 7:34
professionalN_tro_P7-Nov-11 7:34 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 7:37
zahra19917-Nov-11 7:37 
GeneralMessage Removed Pin
7-Nov-11 8:04
professionalN_tro_P7-Nov-11 8:04 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 8:14
zahra19917-Nov-11 8:14 
GeneralMessage Removed Pin
7-Nov-11 8:41
professionalN_tro_P7-Nov-11 8:41 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 8:44
zahra19917-Nov-11 8:44 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 8:58
zahra19917-Nov-11 8:58 
AnswerRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
BillWoodruff7-Nov-11 19:32
professionalBillWoodruff7-Nov-11 19:32 
QuestionPound sign in XML Pin
RugbyLeague7-Nov-11 1:54
RugbyLeague7-Nov-11 1:54 
AnswerRe: Pound sign in XML Pin
Reiss7-Nov-11 3:32
professionalReiss7-Nov-11 3:32 
GeneralRe: Pound sign in XML Pin
RugbyLeague7-Nov-11 3:37
RugbyLeague7-Nov-11 3:37 

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.