Wiki Home

Transparent Labels Bolded During Screen Updates

Namespace: WIN_COM_API
I'm sure you've all seen this behavior: On XP transparent labels will start to get bolder and Bolder and BOLDER as various form elements are updated.

One workaround is to subclass your labels as follows:

  * prevent bleeding
  Backstyle   = 1  && opaque
  ColorSource = 1  && form's Color Scheme
  Style       = 4  && Themed Background only

This fixes the problem _BUT_ eliminates the ability to have transparent labels :(

Has anyone discovered a workaround to this problem that permits the use of transparent labels without the unintentional bolding effect?

Note: The following techniques do not fix this problem:
- Disabling themes (_Screen.Themes = .F.)
- This Form.Draw()
- This Form.Paint()
- This Form.LockScreen = .T. [updates] This Form.LockScreen = .F.

This Form.Refresh() temporarily corrects the problem - but this seems like an expensive solution (and how to know when to trigger this?)

Potential Solution

Toggling offscreen bitmaps off and then on again seems to magically correct this behavior for transparent labels. This technique does NOT correct problems with unwanted caption bolding of transparent checkbox controls.

sys(602,0) && disables off-screen bitmaps
sys(602,1) && re-enables off-screen bitmaps

Just disabling off-screen bitmaps (without the toggle) seems to also work. But, in searching the UT archives, I've seen many posts expressing concern about VFP's screen update behavior when off-screen bitmaps are disabled.

Any comments on this solution? I'm wondering if anyone can confirm my findings? I'm also interested in hearing about any downsides to this approach.

Malcolm Greene

In digging into this, I've only been able to trigger this when Lock Screen is set to .T., the form is refreshed, and then Lock Screen is set to back to .F. from code called from a control. For example, in the Valid method of a textbox, I call a custom RefreshForm method of the form. That method does this:

This.LockScreen = .T.
This.LockScreen = .F.

When I tab out of the textbox, the labels on the form get bolder. Commenting out This.LockScreen = .T. or This.Refresh() prevents this from happening. SYS(602) did nothing for me.

Since a combination of Lock Screen and Refresh seems to be the culprit, the workaround is to avoid using Lock Screen. The Windows API Lock Window UpdateOffsite link to
does something very similar, so changing the above code to:

declare integer LockWindowUpdate in Win32API integer nHandle

has the desired effect of locking the screen during updates and not bolding labels.

--Doug Hennig

This was driving me crazy this past weekend. Every time the page resized. I found that forcing the label's Caption property stopped the bleeding:

** I put this in my form's Resize.
This.lblSearch.Caption = This.lblSearch.Caption
This.lblResult.Caption = This.lblResult.Caption

Bleeding stopped!

-- Kevin Ragsdale

The reason for this bug can be found here:
Pitfalls of transparent rendering of anti-aliased fonts

Carlos Alloatti
( Topic last updated: 2007.11.11 02:44:57 AM )