Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blurry form label captions in WIN7

Status
Not open for further replies.

TomSlayton

Programmer
Oct 21, 2011
19
US
Hi All,

Wondering if you are seeing blurriness in your form lables on WIN7 when you resize your forms. If so, how have you handled that?

Best,

Tom.
 
what font are the labels?

does the problem go away of you change to Segoe UI ?

hth

n
 
The font is the default Arial 9pt, I changed it to the one you specified and I still get the blurry/bold effect. weird.
 
I actually found the work around for this. I had the backstyle of my label set to transparent. When I resized the form the labels randomly went to a blurry/bold state. By resetting the backstyle to opaque the behavior is normal. I guess the thing is to set the label to have the same backcolor as its parent.

The discussion in the post below gave me the hint about this.
 
Setting the BackColor to the same as the parent has another advantage.

If you want to place the label on top of a line or a shape, you don't see the line bleed through into the label. You can also place a space at each end of the caption, to make the label stand out slightly from the line.

I realise this is pretty obscure. I can only say that if you've ever wanted to do anything like that, you soon realise the value of putting THIS.BackColor = THIS.Parent.BackColor in the Init of your base label class.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
It's a known bug caused by clear type technology. There's another known workaround for it than setting Themes=Themes. Might also do the trick. The effect comes from redrawing of the caption at different screen position without first clearing all font/text pixels. This leads to blurry edges.

The fix that was proposed was to do this in a label base class Refresh event:

Code:
Local lcCaption
lcCaption = This.Caption
This.Caption = ""
This.Caption = lcCaption

It did work in XP, but hasn't in Vista and later, as far as I remember.
A much harder thing to do is Thisform.Cls() in the resize event of forms. You might do so in form.Refresh(), too.

Bye, Olaf.
 
Olaf,

form.Refresh() has never worked for me. Well, I shouldn't say never, it has been sporadic.

.Themes = .Themes could also be added to a form base class too if someone was so inclined.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
The point rather is Thisform.cls(), not where you do it, it works in Resize(). It might also work in Label.refresh(), but that would cause a full form redraw every time any label is refreshed.

At first sight, .Themes = .Themes has no effect, but .Recordsource = .Recordsource also has in some cases. Once you know it's a redraw issue with ClearType and once you know Themes cause a slight color gradient on the form background, you can image what a .Themes reset does, if that's what's triggered: It causes a redraw. Setting the caption to "" for a moment also causes a full redraw of the label rectangle so the reset caption is drawn on a clear background. At least that's the idea.

I think if you want to ensure only the least area of a form is redrawn you will need to dig into winforms and use Win API to cause the redraw in a more native way than what foxpro offers.

Bye, Olaf.

 
I did a bit of experimenting.

Label refresh isn't sufficient. Also Thisform.Refresh() is only half an event. It's not always triggered, when a WM_PAINT is sent to the form, but form.Resize() is triggered, even if the form is not really resized, but just drawn first time or moved. or redrawn, becuase a window in front is moved away.

Both THISFORM.THEMES = THISFORM.THEMES and THISFORM.CLS() followed by a refresh call work.

If you have a huge form with many controls and are concerned about flickering, first be reminded we're in 2012, for at least a decade 3d games redraw the full screen 30-60 times a second and do much more than just 2d shapes and font driven text. Still for the purpose of showing how little calls you need in the windows API, I also tested to only invalidate and redraw one label area via this code in a form.resize(), and that works, too:

Code:
#Define cnTop    1
#Define cnLeft   2
#Define cnWidth  3
#Define cnHeight 4

DECLARE LONG InvalidateRect IN user32 LONG, STRING, LONG
DECLARE LONG UpdateWindow In user32 LONG

Local loCntrl, lcRectStruct, lcCaption

loCntrl = Thisform.label2

lcRectStruct = ;
   BinToC(Objtoclient(loCntrl,cnLeft)) + ;
   BinToC(Objtoclient(loCntrl,cnTop )) + ;
   BinToC(Objtoclient(loCntrl,cnLeft)+Objtoclient(loCntrl,cnWidth )+1) + ;
   BinToC(Objtoclient(loCntrl,cnTop )+Objtoclient(loCntrl,cnHeight)+1)   

lcCaption = loCntrl.Caption
loCntrl.Caption = ""

InvalidateRect(thisform.hwnd, lcRectStruct, .T.)
UpdateWindow(thisform.hwnd)

loCntrl.Caption = lcCaption

InvalidateRect(thisform.hwnd, lcRectStruct, .T.)
UpdateWindow(thisform.hwnd)

So, even if your PC is old, you can simply put the Themes or Cls() solution into form.resize, if you want to only redraw areas of text, you could loop through thisform.Objects() and make InvalidateRect calls for each label or header or commandbutton, whatever could include text. I may not be worth the struggle, as only in few cases with larger empty areas this will come close to the whole form area anyway.

So the short solution is to put this into form.resize():
Code:
Thisform.cls() && or Thisform.Themes = Thisform.Themes
Thisform.refresh()

Bye, Olaf.
 
So the short solution is to put this into form.resize():
Not trying to belabor the point, but what if you aren't using resize?
I see the blurry caption behavior whenever anything on the screen is updated, whether it be a textbox, caption, even a WAIT WINDOW... I don't necessarily want to resize the form in order to reset the labels' captions.
Now Thisform.cls() may work fine instead of .Themes = .Themes, I haven't tried it, but I just wanted to point out that it can be used in a user defined form method rather than a global form method.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Reread please:

but form.Resize() is triggered, even if the form is not really resized, but just drawn first time or moved. or redrawn, because a window in front is moved away.

If you're not convinced, SET EVENTTRACKING ON and see for yourself, how often the resize event occurs even without resizing.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top