Joachim,
Here's some code to get the Windows dialog font, the one for the "Message Box" item in the Advanced Appearance dialog (Display Properties > Appearance tab > Advanced button):
- Code: Select all
cgFont := OSWidget abtDefaultDialogFont.
cgFontStruct := cgFont queryFont.
cwFontList := CwFontList fontStruct: cgFontStruct.
The font list is what CwWidgets need. I haven't tested this on Vista, but would be surprised if it worked any differently.
Here's a method to scale, bold and/or italicize a CwFontStruct, I use this to create different versions of whatever font the user has chosen in Display Properties:
- Code: Select all
!CgFontStruct publicMethods !
scaled: scaleFactor bold: isBold italic: isItalic
"Answer a version of the receiver modified by scaling its point size, and/or changing
bold and italic attributes. A nil parameter leaves the attribute unchanged."
| fontDescription wildcardDescription matchingNames |
fontDescription := self logicalFontDescription.
(wildcardDescription := CgLogicalFontDescription wildCard)
fontFamily: fontDescription fontFamily.
scaleFactor isNil
ifTrue: [wildcardDescription points: fontDescription points]
ifFalse: [wildcardDescription points: (fontDescription points asNumber * scaleFactor) rounded printString].
isBold isNil
ifTrue: [wildcardDescription weight: fontDescription weight]
ifFalse: [wildcardDescription weight: (isBold ifTrue: ['bold'] ifFalse: ['medium'])].
isItalic isNil
ifTrue: [wildcardDescription slant: fontDescription slant]
ifFalse: [wildcardDescription slant: (isItalic ifTrue: ['i'] ifFalse: ['r'])].
matchingNames := CgDisplay default listFonts: wildcardDescription name maxnames: 1.
^matchingNames isEmpty
ifTrue: [self]
ifFalse: [CgDisplay default loadQueryFont: matchingNames first]! !
Hope that helps,
Bob