![]() |
Bug with XTFuncChangeWindowFont |
Post Reply
|
| Author | |
JohnCrenshaw
Groupie
Joined: 08 September 2006 Status: Offline Points: 65 |
Post Options
Thanks(0)
Quote Reply
Topic: Bug with XTFuncChangeWindowFontPosted: 03 October 2006 at 11:15am |
|
I just noticed that you have a function to change the font in a screen. Since I had to do something like this myself recently I looked at your implementation.
There is a bug in the function resulting from Microsoft's failure to document anything right. I know because I had an identical bug in my own implementation for over a year before I found out what was wrong.
You start the function (as I did) by grabbing the TEXTMETRIC for the old and new fonts. Then when you are converting you use (tmNew.tmAveCharWidth / tmOld.tmAveCharWidth) as your normalization ratio. This is the problem. In windows Dialog units ARE calculated using the average character width HOWEVER, the REAL average character width is used, not the "AveCharWidth" in the text metric (which is actually just the width of 'x')
Believe it or not, this does make a significant difference, both functionally and cosmeticly. Here is a snippet from my code that made all the difference in fixing this:
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |