c++ - Correct method for redrawing a layered window -
i have window created ws_ex_layered
window style. drawing onto memory bitmap using gdi+, , using updatelayeredwindow
update graphical content of layered window. intend use window main window of application, require redraw frequently.
seeing layered windows not receive wm_paint
windows message[?], need come appropriate method re-drawing window. optimisation not essential, it's nice have cake , eat too. therefore, in search of "correct" method use.
here thoughts far:
i guess it's idea render onto off-screen bitmap before
bitblt
ing or similar.60 frames rendered per second should (more than?) enough (but how compare other applications' frame rates?).
possible solutions:
use
settimer
sendwm_timer
message on regular basis.useful because through specifying time-out value, can achieve desired frames per second, without requirement measure duration "frame" takes rendered.
would cause input or other lags due frequency , speed of messages.
render frames when particular events occur, such window resize.
would require me figure out events require redraw.
would reduce amount of unnecessary frames being rendered.
render frames when there no messages in message queue, checking
peekmessage
.this might slow down processing of window messages.
this cause high cpu usage because more frames necessary being processed.
create new thread perform render loop.
- timing calculations have performed in order maintain steady frame-rate.
layered windows don't receive wm_paint
messages otherwise generated after window visibility changed, won't prevent them receive message @ all.
you can continue use invalidaterect
change window update region, wait wm_paint
in window procedure, draw contents in bitmap , call updatelayeredwindow
change window contents. can use method request redraw when content of window changes, example, when button pressed, or window has been resized (or activated/deactivated).
Comments
Post a Comment