winapi - Can I improve upon window redraw and if so how can I? -
some years ago (2008) wrote online child support calculator using php/javascript/ajax/css advanced child support calculator - may explain replicating.
some time after (2009 think) started writing equivalent windows , revisiting this. fundamentals of version working.
however, have issue window noticeably flickering/changing when controls dynamically added , window redrawn/rebuilt.
note! calculator specific australia.
in short i'm looking way, if possible, refresh/re-display/redraw window after components have been added.
basically, windows controls need dynamically added/removed depending upon scenario (number of adults , children involved).
adding or removing child or adult or performing calculation, results in complete rebuild of window. is, existing controls destroyed , valid controls added (this perhaps minimised via complex logic).
the issue controls removed briefly reappear (in ordered fashion) causing display flicker (for want of better description).
the following screen shots demonstrate complexity factor (such child has drop down each defined adult), not flicckering(sic).
here's screen shot of initial display (ok pretty ugly @ present) :-
and if adult added (note child has extra dropdown adult 3, new adult):-
and now, adult (as above) , child:-
coding wise, there rebuildall
function. has 2 main stages. (1) removal of controls. (2) rebuild (recreation) of appropriate of controls (create window
, sendmessage
's , showwindow
)
at minimum there 61 controls. number of controls 23 + ((#children * 12) - 2) + (#children * (#adults * 8 )) + ((#adults * 10) -4). it's suffice number of controls increases rapidly/exponentially.
i suspect might possible postpone showwindow
untill after of builds have been done. solution, simple (theoretically) this, assuming feasible or there way circumvent need change code remove 'showwindow' , add showwindow @ end of builds?
note replacing individual showwindow
's 1 reduced "flicker" didn't eliminate it. (as per update below).
as endnote i'm pretty sure should feasible windows program have date poor reflection of speed of browser/javascript version, same thing on windows (albeit 64bit).
update
i went through , commented out showwindows
in additem????
functions , added showwindows
function calls functions. has improved matters. however, numerous destroywindow
calls still causes flickering when removing of controls. guess i'm looking can disable them apparently doing equivalent of showwindow
.
update 2
i have found sendmessage(hwnd, wm_setredraw, false, 0);
(true turn drawing on). however, appears supress destroywindow
in display aspect of control remains (the controls don't appear respond though).
by process of elimination have cured flicker combination of showwindow
's , wm_setredraw
's @ pertinent points.
to briefly re-describe issue. when adding child or adult, or performing calculation. entire display rebuilt. rebuild consists of 2 phases. first, destroying existing control windows , adding new/replacement set of window's controls.
the resolution :-
- issue
showwindow(hwnd,sw_show);
(for main/containing window) after pre-existing windows control's had been destroyed. - issue wm_setredraw false message per
sendmessage(hwnd, wm_setredraw, false, 0);
before rebuilding windows controls. withoutshowwindow
's being used. - build windows controls via various functions.
- finally, when windows controls have been built, issue
showwindow(hwnd,sw_show);
(for main/containing window).
rather seeing controls appear , disappear, "the flickering". window blank while , controls displayed @ once.
i'm still confused going on though, due to:-
after thought decided use messagebox
after destroys. when message displayed window blank. however, when button clicked , processing resumed then, in situations when number of controls relatively high, controls appear , disappear in orderly fashion, albeit momentarily.
my guess, creating control in area existing control had been, causing previous control momentarily display.
Comments
Post a Comment