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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Annoying "Bug" involving regional settings

Status
Not open for further replies.

ADoozer

Programmer
Dec 15, 2002
3,487
AU
ok, i know what the problem is.. and i can work around it. But i cant find a solution to the problem and hope that somebody here has encountered and overcome the problem.

im working on a project which currently supports 3 languages (English(UK) Dutch(Netherlands) and Polish) the font size is set to arial 16 for all text within the program which is fine.

The fonts work fine for all regional settings until the project is closed and reopened. at which point vb in its infinate wisdom changes all the font sizes to 15.75 (apparently something to do with screen resolution or something equally as bizzare) now when i come to load my app with the dutch regional settings it errors saying there is a fault with the font and defaults to times new roman size 8 (note. english and polish still work as desired)

the solution i have (which is very annoying) is to open the frm file and replace all font size 15.75 with 16 and hey presto problem solved.

my question simply is. can VB be forced to save the settings i supply (size 16)

also what is special about dutch(netherlands) that causes this font problem only to rear its ugly head?

alas google let me down in finding the ultimate solution, but i know you guys in here rock the vb

thanks in advance

If somethings hard to do, its not worth doing - Homer Simpson
 
ADoozer,

I have no input regarding the regional settings issue but;

It is quite normal for Font sizes/ settings to end up with values which vary a little from the values specified, even TruType fonts which on the face of it are 'Truly' scalable will only produce a finite number of stepped font sizes. The steps of sizes available in a font is also affected by the device being printed to so you may for example do;

FontSize = 16

But when you examine the value of FontSize you may get 15.75 in a screen form and something different say 15.83 on a printer device. These values being the nearest the system can get to the intended setting of 16 on the device in question.

regards Hugh,





 
yes, i agree with what you say.

However what is special about dutch that causes the text to error and default to a different size. (all my googlings seem to point to dutch being the most popular cause of this error) this is all tested on the same pc under exactly the same conditions (exception of the regional settings) so its not an issue with different drivers/screen resolutions/print settings etc


If somethings hard to do, its not worth doing - Homer Simpson
 
ADoozer,

The following is working for me in English(UK) and Dutch(Netherlands). IDE and .exe versions tested.

Private Sub Form_Activate()
Print FontSize 'I get 16.2 in English and 16,2 in Dutch
End Sub

Private Sub Form_Load()

FontName = "Arial"
FontSize = 16

End Sub

Have you tried running a test as simple as this?
Maybe you do indeed have a fault in the Font file or a Dutch specific part of it. Have you tried running the code on another machine?

regards Hugh
 
your missing the point.

try this.

add a label, set its font to arial and size to 16, run the "simple test" and in my case it works for dutch and english.

now close the project and reopen it (this is the point where VB changes the value from 16 to 15.75)

now try running the program again, again in my case English works and dutch does not.

Yes i could code a "setup" into the program where i set all my labels to font size 16 but i shouldnt need to do this.

If somethings hard to do, its not worth doing - Homer Simpson
 
ADoozer,

So I put a Label on a Form. Set the Label's Font to 16 point Arial from the IDE then did;

Private Sub Form_Activate()
Print Label1.FontSize
End Sub

Ran it in the IDE, Quit the IDE, reloaded it in the IDE ran it again, no problem. Same tried with .exe.

All results English and Dutch reported 16.2, without error.
ref. VB6 sp6 and Windows XP prof fully service packed

Have you tried it on another machine yet?

Hugh
 
windows 2000 pro full service packs, Visual studio 6 enterprise sp6.

windows xp pro full service packs, visual studio 6 enterprise sp6 (* 2).

and the problem still persists.

So I put a Label on a Form. Set the Label's Font to 16 point Arial from the IDE then did...

did you look at the *.frm file? had your size 16 been modified to 15.75?


im not alone in this problem

thanks.

If somethings hard to do, its not worth doing - Homer Simpson
 
Adoozer,

Seems I am not helping much except to say that I am not getting the problem you describe. This is my .Frm file and it does not change when regional settings are changed from English to Dutch. My intended FontSize of 16 stays modified to 16.2 in both cases.

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2400
ClientLeft = 48
ClientTop = 432
ClientWidth = 3744
LinkTopic = "Form1"
ScaleHeight = 2400
ScaleWidth = 3744
StartUpPosition = 3 'Windows Default
Begin VB.Label Label1
Caption = "Label1"
BeginProperty Font
Name = "Arial"
Size = 16.2
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 588
Left = 384
TabIndex = 0
Top = 480
Width = 2028
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
Print Label1.FontSize
Print Label1.FontName
End Sub

Pause for thought....

All my foregoing tests for you have been done on a screen res of 1920*1200 at 120dpi. I have however just run a test on another of my pcs with the same software spec but 1280*1024 res at 96dpi and my intended 16 point does indeed get modified to your 15.75. However the change from 16 to 15.75 happens under English and/ or Dutch. Switching the regional setting makes no difference.

It seems to me that software compiled on the first of my machines may be different from that developed on the second one (re the intended vs actual font size set in code) which worries me a little, but regional settings (English vs Dutch) do not seem to be having any affect.

Running code developed on the first machine (1920*1200) on the second gives a reported fontsize of 16.5 (initially modified to 16.2 on the first machine).
Running code developed on the second machine(1024*1200) on the first gives a reported fontsize of 15.6 (initially modified to 15.75 on the second machine).

Could be we both need help from someone else. Is anyone out there?

regards Hugh,
 
>my question simply is. can VB be forced to save the settings i supply (size 16)

No, sadly not

Firstly, the font settings you make are actually for a logical font which the GDI font mapper converts to the closest possible physical font. And, among other things, this conversion involves logical inches. And the DPI setting for logical inches is user selectable (and is typically 96 if you are using 'small fonts' rather than 'large fonts'). And VB saves, as far as I am aware, info from the physical font from the control, not from the logical font that you have requested. So next time that you load the project you get what VB and the GDI decided was the closest match, not what you originally entered, as the font size. There is no way that I am aware of to change this behaviour.

As for the error, I suspect that is because you are getting a comma being used as a decimal seperator when saving the project, which VB does not like loading back in - but then I'd expect to see you having the same problem with the Polish region as well.


The following rough function is one way of telling you the actual physical font point size (for TrueType and OpenType fonts) that you'll get on your current display for a requested point size:
Code:
[blue]Private Function GetPhysicalFontHeight(ParentForm As Form, RequestedFontSize As Single) As Single
    Dim PointsPerInch As Long
    Dim DPI As Long
    PointsPerInch = 72
    DPI = GetDeviceCaps(ParentForm.hdc, LOGPIXELSY) ' Pixels per inch vertically
    GetPhysicalFontHeight = CInt(RequestedFontSize * DPI / PointsPerInch) * PointsPerInch / DPI
End Function
[/blue]

 
thanks for the info mike, i still find it rather odd that there is no fix for this.

does nobody write apps for the dutch?

i suspected the comma may be the issue (as i read it on many sites) however when i look at the *.frm file it is indeed a decimal point (15.75 as stated)

since posting i have looked back at the polish, and it seems the reason that worked was due to the decimal seperator in the language settings being a decimal point (i dont know if this was default or an accident) but change it to a comma and presto polish no longer loads.

so far i see my only option is to set the font size in code, which is gonna be a pain in the a$$ given the amount of controls.

thanks for the input

If somethings hard to do, its not worth doing - Homer Simpson
 
aha. i never got round to testing the compiled program.

very frustrating "bug" non the less. Im just glad im not a dutch programmer.



If somethings hard to do, its not worth doing - Homer Simpson
 
Dutch programmers would use the Dutch version of VB on a Dutch version of the OS rather than the English version on an English version OS configured to Dutch regional settings ...

Yes, VB was released in multiple localised versions, including French, German, Italian, Japanese, Korean, Spanish, Traditional Chinese, and Simplified Chinese (although in truth I'm not certain that there was specifically a Dutch version; they probably use the German version).

The following MAY be of interest to you:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top