Page 1 of 1

SmartErase!

Posted: Tue Mar 17, 2009 3:47 pm
by srod
Update. 18th March 2009.

If you apply SmartErase to a particular window/control, but wish to exlude some child control or other from being removed from the erasing process (such as a toolbar), then simply set a Window property for the child control as follows :

Code: Select all

SetProp_(childHwnd, #SmartErase_IGNORECHILD, 1)
This child will then not be excluded from the erasing of it's parent.

Useful for keeping PB toolbars transparent etc. (See post below regarding toolbars).

You will of course need to remove this property yourself before you destroy the control in question. I did not automate this because SmartErase would then have to subclass the control in order to remove the property and that seemed like overkill in this case.

Download is through the nxSoftware site.

=============================================


Hi,

on a drive to reduce flicker in an application I am working upon when the user resizes the main window prompted me to create this little utility (Windows only).

It is similar to SmartWindowRefresh() in the way it is used, but (and I have never had any success with SmartWindowRefresh()) in tests, SmartErase has resulted in some drastic reductions in flicker.

Like SmartWindowRefresh(), SmartErase() is not guaranteed to work with any particular project. Unlike SmartWindowRefresh(), however, you apply SmartErase() not necessarily to an entire window, but to individual windows or parent controls as appropriate. Like SmartWindowRefresh(), SmartErase() would ideally be used in combination with other techniques (such as using #WS_CLIPCHILDREN and so on) for reducing flicker.

The idea is that you would generally apply ‘SmartErase’ to a parent window/control (e.g. a container gadget) whose child gadgets flicker inordinately when dynamically resized etc. SmartErase() will then assume responsibility for erasing that window/control's background whilst following certain rules (e.g. ignore all child windows) etc. SmartErase() can even be instructed to bypass all erasing for a particular window/control which is useful if the window is completely covered by child controls etc.

Very simple, quite crude, but with the 6 demo programs tested on XP and Vista, it can be damn effective! :)

The download includes the full source, six demos and a very short user manual. Please read the manual before attempting to use this utility as it contains some important info.

All of the the demo programs have SmartErase() disabled. Run them with xp themes enabled and resize the main window to see some appalling flicker. Then uncomment the appropriate line(s) to see the effect SmartErase() may or may not be having.

My thanks to Kinglestat for helping to test the code and the demos.

Please proceed to the nxSoftware site for the download (Freeware section).

Regards.

Posted: Tue Mar 17, 2009 7:06 pm
by kinglestat
Thanks for sharing

Posted: Tue Mar 17, 2009 11:45 pm
by PB
Not bad. :) It certainly helps a lot here on XP!

Posted: Wed Mar 18, 2009 5:50 am
by ts-soft
Works fine on vista :D

Posted: Wed Mar 18, 2009 8:36 am
by Mistrel
New solutions for reducing flickering are always welcome! Sometimes all it takes is the right creative combination. :)

Posted: Wed Mar 18, 2009 10:07 am
by Kwai chang caine
Thanks MASTER for sharing and furthermore the source 8)

It's just for inform and help you. :oops:
I believe that "Flickering" it's like when the gadget jerk :roll:
If it's that, on W2000 when i resize that's always flickering
It's surely normal, because you talk of XP and vista.
Surrely W2000 is too old like OS

So Again thanks 8)

Posted: Wed Mar 18, 2009 10:55 am
by srod
Kwai, I see no reason why it should not work on Win2000. Let me fire up the VM and take a look.

Posted: Wed Mar 18, 2009 11:03 am
by srod
Kwai, it works fine on Win2000 here.

First thing is that Win2000 does not allow you to enable XP themes and so there is not as much flicker anyhow. More importantly, each of the SmartErase demo programs has SmartErase disabled! You must enable it by uncommenting the marked lines! Now did you do this?

The thing is that SmartErase should work on all versions of Windows because it is in principal a very simple affair!

Posted: Wed Mar 18, 2009 11:25 am
by gnozal
srod wrote:Kwai, it works fine on Win2000 here.
Quickly tested on NT4 : works very well !

Posted: Wed Mar 18, 2009 11:33 am
by srod
Excellent. :)

I just applied SmartErase to my current app which has a rather complex GUI (including the flickery panel gadgets!) and it has removed absolutely all flicker! (Tested on Vista and XP!) Even the panels no longer flicker, but I think that has something to do with the fact that they are within Nexus splitter gadgets with a fixed section (although without SmartErase these same panels flicker appallingly!)

Huh, just goes to show; sometimes the dumbest ideas are the most effective! :wink:

Posted: Wed Mar 18, 2009 12:49 pm
by srod
Tip.

If you apply SmartErase to a window containing a toolbar, then depending on the toolbar's styles, the toolbar may not get erased at all. To combat this simply remove the #TBSTYLE_TRANSPARENT and #TBSTYLE_FLAT styles from the toolbar.

For a PB toolbar, simply remove the #TBSTYLE_TRANSPARENT style :

Code: Select all

SetWindowLong_(ToolBarID(#MyToolbar), #GWL_STYLE, GetWindowLong_(ToolBarID(#MyToolbar), #GWL_STYLE)&~#TBSTYLE_TRANSPARENT)
(My thanks to Kiffi for reporting this problem.)

Posted: Wed Mar 18, 2009 1:03 pm
by srod
Update. 18th March 2009.
If you apply SmartErase to a particular window/control, but wish to exlude some child control or other from being removed from the erasing process (such as a toolbar), then simply set a Window property for the child control as follows :

Code: Select all

SetProp_(childHwnd, #SmartErase_IGNORECHILD, 1)
This child will then not be excluded from the erasing of it's parent.

Useful for keeping PB toolbars transparent etc. (See post above regarding toolbars).

You will of course need to remove this property yourself before you destroy the control in question. I did not automate this because SmartErase would then have to subclass the control in order to remove the property and that seemed like overkill in this case.

Download is through the nxSoftware site.

Posted: Wed Mar 18, 2009 4:32 pm
by Kwai chang caine
Master SROD wrote:You must enable it by uncommenting the marked lines!
:oops:

Have i need to say something other :oops:
My shame is without limit :oops:

I'm tired to be a trumpet :oops: :?
I promise to you, that i don't do that purposely, it's incredible no ??
Because i can to be again more IDIOT :D

One thousand of thanks for your great code, sharing and tolerance

Good news
Your code works also on W2000 :lol: