﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3946	_ChooseFont() updated defaults	argumentum	Jpm	"added Default(keyword) to entries and color lookup, as the default of 0x0 is not always a visible color.

{{{
; #FUNCTION# ====================================================================================================================
; Author ........: Gary Frost (gafrost)
; Modified.......: argumentum
; ===============================================================================================================================
Func _ChooseFont($sFontName = ""Courier New"", $iPointSize = 10, $iFontColorRef = Default, $iFontWeight = 0, $bItalic = False, $bUnderline = False, $bStrikethru = False, $hWndOwner = 0)
	Local $iItalic = 0, $iUnderline = 0, $iStrikeout = 0 ,$COLOR_BTNTEXT = 18
	If $sFontName = Default Then $sFontName = ""Courier New"", 
	If $iPointSize = Default Then $iPointSize = 10
	If $iFontColorRef = Default Then
		$iFontColorRef = 0
		$aRet = DllCall(""user32.dll"", ""INT"", ""GetSysColor"", ""int"", $COLOR_BTNTEXT)
		If Not @error Then $iFontColorRef = $aRet[0]
	EndIf
	If $iFontWeight = Default Then $iFontWeight = 0
	If $bItalic = Default Then $bItalic = False
	If $bUnderline = Default Then $bUnderline = False
	If $bStrikethru = Default Then $bStrikethru = False, 
	If $hWndOwner = Default Then $hWndOwner = 0
	$iFontColorRef = BitOR(BitShift(BitAND($iFontColorRef, 0x000000FF), -16), BitAND($iFontColorRef, 0x0000FF00), BitShift(BitAND($iFontColorRef, 0x00FF0000), 16))

	Local $hDC = __MISC_GetDC(0)
	Local $iHeight = Round(($iPointSize * __MISC_GetDeviceCaps($hDC, $LOGPIXELSX)) / 72, 0)
	__MISC_ReleaseDC(0, $hDC)

	Local $tChooseFont = DllStructCreate($tagCHOOSEFONT)
	Local $tLogFont = DllStructCreate($tagLOGFONT)

	DllStructSetData($tChooseFont, ""Size"", DllStructGetSize($tChooseFont))
	DllStructSetData($tChooseFont, ""hWndOwner"", $hWndOwner)
	DllStructSetData($tChooseFont, ""LogFont"", DllStructGetPtr($tLogFont))
	DllStructSetData($tChooseFont, ""PointSize"", $iPointSize)
	DllStructSetData($tChooseFont, ""Flags"", BitOR($CF_SCREENFONTS, $CF_PRINTERFONTS, $CF_EFFECTS, $CF_INITTOLOGFONTSTRUCT, $CF_NOSCRIPTSEL))
	DllStructSetData($tChooseFont, ""rgbColors"", $iFontColorRef)
	DllStructSetData($tChooseFont, ""FontType"", 0)

	DllStructSetData($tLogFont, ""Height"", $iHeight)
	DllStructSetData($tLogFont, ""Weight"", $iFontWeight)
	DllStructSetData($tLogFont, ""Italic"", $bItalic)
	DllStructSetData($tLogFont, ""Underline"", $bUnderline)
	DllStructSetData($tLogFont, ""Strikeout"", $bStrikethru)
	DllStructSetData($tLogFont, ""FaceName"", $sFontName)

	Local $aCall = DllCall(""comdlg32.dll"", ""bool"", ""ChooseFontW"", ""struct*"", $tChooseFont)
	If @error Then Return SetError(@error, @extended, -1)
	If $aCall[0] = 0 Then Return SetError(-3, -3, -1) ; user selected cancel or struct settings incorrect

	Local $sFaceName = DllStructGetData($tLogFont, ""FaceName"")
	If StringLen($sFaceName) = 0 And StringLen($sFontName) > 0 Then $sFaceName = $sFontName

	If DllStructGetData($tLogFont, ""Italic"") Then $iItalic = 2
	If DllStructGetData($tLogFont, ""Underline"") Then $iUnderline = 4
	If DllStructGetData($tLogFont, ""Strikeout"") Then $iStrikeout = 8

	Local $iAttributes = BitOR($iItalic, $iUnderline, $iStrikeout)
	Local $iSize = DllStructGetData($tChooseFont, ""PointSize"") / 10
	Local $iColorRef = DllStructGetData($tChooseFont, ""rgbColors"")
	Local $iWeight = DllStructGetData($tLogFont, ""Weight"")

	Local $sColor_picked = Hex(String($iColorRef), 6)

	Return StringSplit($iAttributes & "","" & $sFaceName & "","" & $iSize & "","" & $iWeight & "","" & $iColorRef & "","" & '0x' & $sColor_picked & "","" & '0x' & StringMid($sColor_picked, 5, 2) & StringMid($sColor_picked, 3, 2) & StringMid($sColor_picked, 1, 2), "","")
EndFunc   ;==>_ChooseFont
}}}
"	Feature Request	closed	3.3.17.0	Standard UDFs		None	Completed		
