Re: checkbox caption wraps!
- From: "Mike Williams" <mikea@xxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Dec 2007 07:53:24 -0000
"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
.
- References:
- checkbox caption wraps!
- From: Jack
- Re: checkbox caption wraps!
- From: Jack
- checkbox caption wraps!
- Prev by Date: Re: Tips on finding memory leaks
- Next by Date: Re: Tips on finding memory leaks
- Previous by thread: Re: checkbox caption wraps!
- Next by thread: Print preview image in a picture box
- Index(es):
Relevant Pages
|