VBA Userform: Text of same font size changes size based on Top property - vba

I have a userform. In multiple cases across several different controls, I have observed the objects with the same Width, Height, Font, and Font Size display different font sizes depending on where they are placed on my userform.
. . . .
Above is an example of this. The two textbox's are both 26H and 48W, with a Left of 90. Both have font Tahoma Regular size 18. The only difference between them is their Top property. And yet visually, the upper one has much wider text than the lower one. The picture on the right has added dots to prove this is not an optical illusion. The upper one can only fit one dot between the letter and the edge. The lower one can fit at least two dots between the letter and the edge.
Can anyone explain why this is happening? What is happening? Or how I could stop it from happening?

Why its happening?
A normal windows graphical application renders in 96dpi/ppi.
However, excel’s rendering system is in 72dpi/ppi,so, when you specify 26 as the height, excel will first convert 72 to 96 dpi.
26 x 96 / 72 = 34.6667
Which means your control height is 34.667 pixels.
This will create artefacts in the rendering of your control.
How can you stop it?
Make sure that the final position of your control and its height has a final pixel position in the form to be a whole number.
You can do this by multiplying by your screen dpi and divide by excel dpi(72)
In your case you can apply a height of 25.5 which will render it correctly.
I hope I solved your answer!!

As Krishna Soni says in this thread, you should use a height of 25.5 for all the reasons he present.
This is equivalent to using controls with a height that is a multiple of 3. Since the rounding of 25.5 is 30, we can take 3 as a multiple of the Top, Height, and Width properties and avoid the text resizing issues.
Seen on Weird change of font size when changing Top proprierty by 1

Related

How can I find the amount of pixels in part of an image?

I have an image and I want to see how many pixels are in different parts of the image. Is there a software I can use to do this?
In Gimp, the "Histogram" dialog applies to the selection, so the pixel count displayed is the pixels in the selection (weighted by their selection level):
In the image below the selection covers the black circle which has a 100px radius. The Pixels value is close to 100²*Pi (314000 instead of 314159).
The Count is the number of pixels between the two values indicated by the handles at the bottom of the histogram.
Of course the selection can have any shape and be obtained with various tools.
I assume PS has something equivalent.

Size windows form in inches

I need to create a form that will be printed. The dimensions will be 4 inches by 4 inches. I only see pixels as the unit when referring to the dimensions of a form. Is there a way to change this to inches? If not, is there a clean conversion from pixels to inches?

vb.net DrawString X-Position

I have problems with positioning within the DrawString method. However, only on the X axis.
No matter what value I recommend for the distance from above - it fits. Therefore, I assume that I have made everything right.
For example, An X in Arial with font size 10, the letter is slightly more than 0.5 mm too far right. If I try it with font size 600, it is more than 35 mm too far right. I suspect that something has to be adjusted depending on the font size and it has nothing to do with the dimensions of the Graphics object.
Does anyone have ideas / experiences / a formula?
If code examples are needed, I can supply them.

Is there any way to convert/compare JasperReports's report 'band height' to/with inches?

I am making labels using iReport and need to make sure they fit with the labels the client uses. I am using label format Avery 5163 which has a height of 2 inches. The labels I'm making need to match up with the labels they will be using to print.
I can only find a 'band height' property in iReport which is definitely not in inches. I could fiddle with the band height until they lined up with the Avery 5163 label heights, but I don't like wasting paper and I have more of these labels with different sizes I'd love to know a way to handle this. Has anyone experienced this or know of any solutions?
As I recall, the dimensions of Jasper Reports labels are defined in "dots", with 72 dots per inch.
So your 2 inch label would require a height of 144 units.

Incorrect image padding

I searched and tried the troubleshooting faqs but can't see a reference to the problem I'm having.
I have the following presets in the resizer section my web.config:
name="kbp600w" defaults="w=600;h=600;mode=max;anchor=MiddleCenter;watermark=kbp600"
name="kbp600" defaults="w=600;h=600;anchor=MiddleCenter;bgcolor=FEF2E1;watermark=kbp600"
name="kbp300" defaults="w=300;h=300;anchor=MiddleCenter;bgcolor=FEF2E1;watermark=kbp300"
I generate my images with the following urls (I generate three different images using the same file):
picture.jpg?preset=kbp600w
picture.jpg?preset=kbp300
picture.jpg?preset=kbp600
So, here's the thing:
The first URL works fine and does everything defined in the preset.
The second URL also works fine and does everything defined in the preset.
The third URL works fine when the image width is larger than the height (landscape), but when the height is the largest dimension (portrait) it resizes the height correctly but the width dimension does not get padded to fill the 600px width but instead becomes whatever size is calculated to maintain the aspect ratio. I need it to always have dimensions of 600 x 600 with padding either on the top and bottom or sides with the appropriate background color for the padding.
Am I doing something wrong?
https://gist.github.com/anonymous/5672886
Use mode=pad and scale=canvas (or scale=both) to always get exactly the requested dimensions.
Without scale=both or scale=canvas, an image < 600x600 in either dimension won't be upscaled or padded.
P.S. Anchor=MiddleCenter is the default, so you don't need to specify that.