Faster window/gadget redrawing! (Windows)
Posted: Fri Mar 17, 2006 2:12 pm
Code updated For 5.20+
There is a SmartWindowRefresh() but I do not really see any difference!
So while fooling around I noticed my resize routine for a program was
generating a whole bunch of erasebackground windows messages.
i was not just using ResizeGadget() but also
SendMessage_(GadgetID(#Gadget),#LVM_SETCOLUMNWIDTH,0,#LVSCW_AUTOSIZE_USEHEADER)
to make my listiconview look nice by automatically sizing the column header.
Sadly this mean that I ended up with twice as many erase background messages being recieved.
Then I came up with this solution...
At the start of your resize/redraw routine or procedure or whatever do this:
SendMessage_(WindowID(#Window),#WM_SETREDRAW,#False,0)
This will disable all redrawing/repainting of the window,
do all the resizing and column adjusting whatever you want now.
Then at the end when your done with all resize and other stuff,
do the following.
SendMessage_(WindowID(#Window),#WM_SETREDRAW,#True,0)
RedrawWindow_(WindowID(#Window),#Null,#Null,#RDW_INVALIDATE)
This will turn redrawing back on,
and then you invalidate the entire window to force a redraw.
This gives (at least me) the functionality that I expected from SmartWindowRefresh()
and I suspect it might also reduce the flicker some people experience.
Because if you do not disable te redrawing
and then do a bunch of gadget resizing or window resizing,
a redraw will occur for each command that modify a gadget or window.
There is a SmartWindowRefresh() but I do not really see any difference!
So while fooling around I noticed my resize routine for a program was
generating a whole bunch of erasebackground windows messages.
i was not just using ResizeGadget() but also
SendMessage_(GadgetID(#Gadget),#LVM_SETCOLUMNWIDTH,0,#LVSCW_AUTOSIZE_USEHEADER)
to make my listiconview look nice by automatically sizing the column header.
Sadly this mean that I ended up with twice as many erase background messages being recieved.
Then I came up with this solution...
At the start of your resize/redraw routine or procedure or whatever do this:
SendMessage_(WindowID(#Window),#WM_SETREDRAW,#False,0)
This will disable all redrawing/repainting of the window,
do all the resizing and column adjusting whatever you want now.
Then at the end when your done with all resize and other stuff,
do the following.
SendMessage_(WindowID(#Window),#WM_SETREDRAW,#True,0)
RedrawWindow_(WindowID(#Window),#Null,#Null,#RDW_INVALIDATE)
This will turn redrawing back on,
and then you invalidate the entire window to force a redraw.
This gives (at least me) the functionality that I expected from SmartWindowRefresh()
and I suspect it might also reduce the flicker some people experience.
Because if you do not disable te redrawing
and then do a bunch of gadget resizing or window resizing,
a redraw will occur for each command that modify a gadget or window.
Code: Select all
SendMessage_(WindowID(#Window),#WM_SETREDRAW,#False,0)
;put your gadget and window resizing and similar code here.
SendMessage_(WindowID(#Window),#WM_SETREDRAW,#True,0)
RedrawWindow_(WindowID(#Window),#Null,#Null,#RDW_INVALIDATE)