FontRequester - Schrifteigenschaften
Verfasst: 05.01.2007 17:21
Wie kann ich Fett/Kursiv/Fett und Kursiv als standard auswählen?
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
; Title: ChooseFont API Dialog
; Author: Fluid Byte
; Date: January 05, 2007
; Compiler: PureBasic v4.02
hdcScreen = CreateDC_("DISPLAY",0,0,0)
lf.LOGFONT
lf\lfHeight = -MulDiv_(FontSize,GetDeviceCaps_(hdcScreen,#LOGPIXELSY),72)
lf\lfItalic = 0
lf\lfUnderline = 0
lf\lfStrikeOut = 0
lf\lfWeight = #FW_BOLD
PokeS(@lf\lfFaceName,"Arial")
DeleteDC_(hdcScreen)
lpcf.CHOOSEFONT
lpcf\lStructSize = SizeOf(CHOOSEFONT)
lpcf\lpLogFont = lf
lpcf\Flags = #CF_EFFECTS | #CF_INITTOLOGFONTSTRUCT | #CF_BOTH
lpcf\rgbColors = TextColor
If ChooseFont_(lpcf)
Debug "FaceName = " + PeekS(@lf\lfFaceName)
Debug "PointSize = " + Str(lpcf\iPointSize/10)
Debug "Italic = " + Str(lf\lfItalic)
Debug "Underline = " + Str(lf\lfUnderline)
Debug "StrikeOut = " + Str(lf\lfStrikeOut)
Debug "Weight = " + Str(lf\lfWeight)
EndIf
Code: Alles auswählen
; Title: ChooseFont API Dialog
; Author: Fluid Byte
; Date: January 05, 2007
; Compiler: PureBasic v4.02
; modified: by teachco
; Date: June 07, 2007
Procedure FontRequester_workaround(fontname.s, underline.b, strikeout.b, italic.b , bold.b, FontSize.l , TextColor.l)
hdcScreen = CreateDC_("DISPLAY",0,0,0)
lf.LOGFONT
lf\lfHeight = -MulDiv_(FontSize,GetDeviceCaps_(hdcScreen,#LOGPIXELSY),72)
lf\lfItalic = italic
lf\lfUnderline = underline
lf\lfStrikeOut = strikeout
If bold
lf\lfWeight = #FW_BOLD
Else
lf\lfWeight = 0
EndIf
PokeS(@lf\lfFaceName,fontname)
DeleteDC_(hdcScreen)
lpcf.CHOOSEFONT
lpcf\lStructSize = SizeOf(CHOOSEFONT)
lpcf\lpLogFont = lf
lpcf\Flags = #CF_EFFECTS | #CF_INITTOLOGFONTSTRUCT | #CF_BOTH
lpcf\rgbColors = TextColor
ChooseFont_(lpcf)
EndProcedure
; Vorbelegung Bsp.
fontname.s = "Verdana"
underline = 1 ; 0: nicht gesetzt , 1: gesetzt
strikeout = 1 ; 0: nicht gesetzt , 1: gesetzt
italic = 1 ; 0: nicht gesetzt , 1: gesetzt
bold = 1 ; 0: nicht gesetzt , 1: gesetzt
FontSize = 20
TextColor = RGB(255,0,0)
FontRequester_workaround(fontname, underline, strikeout, italic , bold, FontSize , TextColor)