Click here to Skip to main content
15,890,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCHtmlView and Windows 7 Pin
Member 810956018-Oct-11 22:57
Member 810956018-Oct-11 22:57 
QuestionTCP Communication Pin
john563218-Oct-11 19:15
john563218-Oct-11 19:15 
AnswerRe: TCP Communication Pin
Goto_Label_18-Oct-11 22:29
Goto_Label_18-Oct-11 22:29 
AnswerRe: TCP Communication Pin
Software_Developer18-Oct-11 22:56
Software_Developer18-Oct-11 22:56 
GeneralRe: TCP Communication Pin
john563218-Oct-11 23:45
john563218-Oct-11 23:45 
AnswerRe: TCP Communication Pin
App_18-Oct-11 23:07
App_18-Oct-11 23:07 
AnswerRe: TCP Communication Pin
jschell19-Oct-11 8:55
jschell19-Oct-11 8:55 
QuestionBeginPaint issues Pin
Waldermort18-Oct-11 9:08
Waldermort18-Oct-11 9:08 
I've created a custom control, using the low level win32 api, which displays an animation. Using a thread I render a frame, or rather update the parts need it, and call InvalidateRect passing the area that was changed. In the main thread I handle WM_PAINT with the BeginPaint EndPaint pair AND use the paintstruct's rect to repaint only the area required.

The rendering is backed by a TimerQueue, an event and a thread that waits on the event.

I couldn't work out why my CPU usage was hovering around 80%. Each frame involves a lot of alpha blending hence the need to only update the changed parts.

After 2 days I've narrowed the problem to BeginPaint. MSDN states, and this is GDI 101, when handling a WM_PAINT message BeginPaint and EndPaint should be called to validate the invalid rect, otherwise windows will continue to post the message.

Well, it's just not happening. The window has not been validated and my code has been rendering the full client area (lot's of work) on each call. If I add a ValidateRect in my handler the problem goes away and CPU down to 0-1%.

My question is why? Is this a bug or am I missing something?
Waldermort

AnswerRe: BeginPaint issues Pin
TheGreatAndPowerfulOz18-Oct-11 12:22
TheGreatAndPowerfulOz18-Oct-11 12:22 
GeneralRe: BeginPaint issues Pin
Waldermort18-Oct-11 21:00
Waldermort18-Oct-11 21:00 
GeneralRe: BeginPaint issues Pin
TheGreatAndPowerfulOz19-Oct-11 5:01
TheGreatAndPowerfulOz19-Oct-11 5:01 
AnswerRe: BeginPaint issues Pin
Chuck O'Toole18-Oct-11 12:52
Chuck O'Toole18-Oct-11 12:52 
GeneralRe: BeginPaint issues Pin
Waldermort18-Oct-11 21:03
Waldermort18-Oct-11 21:03 
GeneralRe: BeginPaint issues Pin
Chuck O'Toole18-Oct-11 23:04
Chuck O'Toole18-Oct-11 23:04 
GeneralRe: BeginPaint issues Pin
Waldermort19-Oct-11 3:46
Waldermort19-Oct-11 3:46 
GeneralRe: BeginPaint issues Pin
Chuck O'Toole19-Oct-11 5:02
Chuck O'Toole19-Oct-11 5:02 
GeneralRe: BeginPaint issues Pin
Waldermort19-Oct-11 5:41
Waldermort19-Oct-11 5:41 
Questionselect and accept socket calls Pin
vikramlinux18-Oct-11 8:33
vikramlinux18-Oct-11 8:33 
AnswerRe: select and accept socket calls Pin
Richard Andrew x6418-Oct-11 8:39
professionalRichard Andrew x6418-Oct-11 8:39 
AnswerRe: select and accept socket calls Pin
Chuck O'Toole18-Oct-11 10:37
Chuck O'Toole18-Oct-11 10:37 
QuestionHow to use a collection Pin
jkirkerx18-Oct-11 7:45
professionaljkirkerx18-Oct-11 7:45 
AnswerRe: How to use a collection Pin
Richard MacCutchan18-Oct-11 22:44
mveRichard MacCutchan18-Oct-11 22:44 
GeneralRe: How to use a collection Pin
jkirkerx19-Oct-11 5:18
professionaljkirkerx19-Oct-11 5:18 
QuestionCompiling DOS Apps With Windows 7 Pin
softwaremonkey18-Oct-11 7:35
softwaremonkey18-Oct-11 7:35 
AnswerRe: Compiling DOS Apps With Windows 7 Pin
Albert Holguin18-Oct-11 7:44
professionalAlbert Holguin18-Oct-11 7:44 

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.