Re: checkbox caption wraps!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Jack" <replyto@it> wrote in message news:ObysKypQIHA.3676@xxxxxxxxxxxxxxxxxxxxxxx

Thank you. I cannot recreate that wrapping on my
computer. In Display Properties> Appearance tab
I have changed Font Size from Normal to Large
and later to Extra Large. In both cases there was
not caption wrapping, but instead of the bottom of the form was cut (cut but not over the screen).

As I said in my previous response, when the dpi changes then the pixel size of the Control (Label or whatever) and the pixel size of the fonts are changed, both in the same porportion, so in theory they will look and behave exactly the same on both machines, except that on the 120 dpi machine the entire Control, including its text, is just a "magnified copy" of the same Control on the 96 dpi machine (as far as its pixel size is concerned). If the text does not wrap on the 96 dpi machine then it should not wrap on the 120 dpi machine . . . BUT . . . there is often a problem if the control is "only just wide enough" to accommodate the text on the 96 dpi machine because when VB creates the new pixel size for the control it will end up being perhaps half a pixel bigger (or smaller) than its twip size dictates, because of the "round up or down to the nearest pixel" thing. In the case of the text however, EVERY CHARACTER in the text can also be about half a pixel bigger (or smaller) than its intended twip size, depending on the specific character. So if the text contains 12 characters then the entire width of the text can be about 6 pixels wider (or 6 pixels narrower) than its intended twip width. This means that the text CAN (but not MUST) be up to 6 pixels different (wider or narrower) than its intended twip size whereas the Control itself will only be about 1 pixel different (wider or narower). In general of course the reduction and / or increase in the pixel size of each character (depending on the specific character) will average out so that the entire text is quite close to its intended twip size, but in some cases it will not (again, depending on the specific characters in the text). There is of course also the possibility that the font you are using does not exist on the target machine (in which case the OS will use the closest match it can find), or that it is a slightly version on that machine than your own. Exactly the same sort of thing can occur in the opposite direction as well (when moving from a 120 dpi machine to a 96 dpi machine) for the very same "whole pixel width for every character" thing). There are all sorts of little things that can make a difference. That's why you sometimes get wrap and sometimes not.

The trick, generally (unless you want to write fully fledged resizing code, which I assume you do not) is to make sure that you set the width of the Control on your development machine to be at least one pixel per character wider than it actually needs to be to have the best chance of avoiding word wrap. In the IDE temporarily set the Form's Scalemode to pixels and set the Caption of the Label or CheckBox to its run time text and then drag the width of the Label (or CheckBox or whatever) inwards until the text just wraps and then drag it out again slowly until it does not wrap. Then look at its Width property and if it is (for example) 86 pixels and if its Caption contains 12 characters then change its Width property to 98. Have you done that? Usually of course you don't mess about like that . . . you just use some common sense and drag out the width of the Control so that you can see it is a fair bit wider than the text it is displaying. Have you done that? Give us some details.

If you've done those things and if you are still getting word wrap on the target machine then there is something else going on (perhaps things being changed somewhere in your code) and you'll need to add some code to write a log for you that contains the run time value of the relevant things, such as control width, TextWidth of its caption (after temporarily assigning its font to a DC which will give you its TextWidth), font name and font size and attributes, as much data as you can get really.

Mike


.



Relevant Pages

  • Re: Text On Picturebox
    ... In the above specific case there would be some output because VB would convert the value 0.5 to a Long and because TextOut would interpret it as a pixel value anyway so it would be at the top left of the PicBox, but you would not initially see the output because it would be drawn into the PictureBox's autoredraw bitmap in memory and VB itself would not know it had been drawn there and VB would therefore not automatically refresh the PictureBox as displayed on the screen. ... As far as StrokePath is concerned, that method is perfect for use on high resolution devices such as printers, and you can fairly easily achieve lots of nice effects with it, but it doesn't work so well on the display because the display has a relatively low resolution. ... The apparent quality of images is of course a subjective thing, but personally I think that on the display you can achieve nicer looking output just by Printing the text in the normal way, because the Print method uses font smoothing whereas the various Path methods do not. ... You need to be a little bit careful with the above Autosize Label method if either the first character or the last character of the text string happens to overhang the edge of its character cell because in such a case the Label Control will often leave a little trail of dots as the user moves it. ...
    (microsoft.public.vb.general.discussion)
  • Re: adjusting fonts to computers dpi settings
    ... font size to 6 it will correct all wrong places. ... Yes, it is possible to run through the Controls changing font sizes in that manner, but personally I would not advise doing so, at least until you have looked into this problem a little further. ... Then at run time it converts those twip values into pixels using the twips per pixel setting of the machine on which the code is currently running (15 twips per pixel on a 96 dpi machine, 12 twips per pixel on a 120 dpi machine, etc, etc) and it sets both their size and position in accordance with the returned values. ...
    (microsoft.public.vb.general.discussion)
  • Re: Custom TTF space character being drawn too narrow but only on some XP PCs
    ... Does the TTF file format have a flag to say that the font is monospaced or is it simply in the definition of the individual characters, each being given the same width? ... For example, MS Excel, at least until recently, uses the old GDI approach, which misrepresents character widths on screen and then prints what the screen shows. ... It takes an approach similar to the EPS spec, in that if any part of the character touches a pixel, that pixel turns black. ... So if your monospace font is not an integral number of pixels in width, any actual character is going to push the line out the right a tad, but a space character won't. ...
    (comp.fonts)
  • Re: Custom TTF space character being drawn too narrow but only on some XP PCs
    ... I wonder whether it's using the right set of Windows API calls. ... For example, MS Excel, at least until recently, uses the old GDI approach, which misrepresents character widths on screen and then prints what the screen shows. ... It takes an approach similar to the EPS spec, in that if any part of the character touches a pixel, that pixel turns black. ... So if your monospace font is not an integral number of pixels in width, any actual character is going to push the line out the right a tad, but a space character won't. ...
    (comp.fonts)
  • Re: How to read a charecters from and image?
    ... now this thread is gonna pop up every time some kiddie Googles how to ... You can then easily try to match each character in the font, pixel per ...
    (comp.lang.ruby)