I am using DrawText() to handle text on UI. When people change the Display from 100% to 150% on Control Panel, the size of the text changes, and the alignment won't look right.
I am new to PB, so is there a way to fix the size, or an alternative to DrawText()?
How to make size of text not affected by Display Setting
-
Little John
- Addict

- Posts: 4869
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: How to make size of text not affected by Display Setting
Hello sjuwing. For custom drawn forms, DrawText() is the way to go, although the environment variables have to be taken into consideration. Checking the display resolution before drawing the UI would solve such issues. Please take a look at this example which I posted about a month ago, and perhaps you'd get some idea. The routine determines the suitable font size before using it:sjuwing wrote:change the Display from 100% to 150% on Control Panel, the size of the text changes, and the alignment won't look right...
http://www.purebasic.fr/english/viewtop ... nt#p418173
Hope it helps.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: How to make size of text not affected by Display Setting
Thank you both. It's helpful.
TI-994A's solution is more specific to my question. However, it ran into infinite loop sometimes. The revised version works for me.
I also tried another way. Since my app only targets to Windows (XP or above), so it looks works for me.
TI-994A's solution is more specific to my question. However, it ran into infinite loop sometimes. The revised version works for me.
I also tried another way. Since my app only targets to Windows (XP or above), so it looks works for me.
Code: Select all
Procedure ConvertFontSize(iRawSize.l)
iDpi.l = GetDeviceCaps_(GetDC_(0), #LOGPIXELSX)
iFontHeight.l = Int(iRawSize / 72 * iDpi)
iNowSize.l = Int(iFontHeight / iDpi * 72)
ProcedureReturn iNowSize
EndProcedure