WildByDesign Posted 1 hour ago Posted 1 hour ago I'm trying to learn more about the _WinAPI_CreateFont function. In particular, I'm trying to understand how to properly set the $iPitch parameter. The help file shows: Quote [optional] Specifies the pitch and family of the font. The two low-order bits specify the pitch of the font and can be one of the following values: $DEFAULT_PITCH, $FIXED_PITCH, $VARIABLE_PITCH The four high-order bits specify the font family and can be one of the following values: $FF_DECORATIVE - Novelty fonts. Old English is an example $FF_DONTCARE - Use default font (Default) $FF_MODERN - Fonts with constant stroke width, with or without serifs. Pica, Elite, and Courier New are examples $FF_ROMAN - Fonts with variable stroke width and with serifs. MS Serif is an example $FF_SCRIPT - Fonts designed to look like handwriting. Script and Cursive are examples $FF_SWISS - Fonts with variable stroke width and without serifs. MS Sans Serif is an example By default, most example functions throughout the forum use 0 for that parameter. The part that I don't understand here is the two low-order bits and four high-order bits for the parameter. I don't understand how that works for this specific parameter. My assumption is that this is different from doing a simple BitOR of the two values. How would I set the $iPitch parameter, for example, $DEFAULT_PITCH and $FF_SCRIPT? Thank you. Here is the example script for _WinAPI_CreateFont from the docs as a starting point: expandcollapse popup#include <FontConstants.au3> #include <StructureConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WinAPISysWin.au3> Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC HotKeySet("{ESC}", "_Exit") $g_tRECT = DllStructCreate($tagRect) DllStructSetData($g_tRECT, "Left", 5) DllStructSetData($g_tRECT, "Top", 5) DllStructSetData($g_tRECT, "Right", 250) DllStructSetData($g_tRECT, "Bottom", 50) $g_hDC = _WinAPI_GetDC(0) $g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') $g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont) _WinAPI_SetTextColor($g_hDC, 0x0000FF) _WinAPI_SetBkColor($g_hDC, 0x000000) ; comment next line to get black background instead of transparent one _WinAPI_SetBkMode($g_hDC, $TRANSPARENT) While 1 _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER) Sleep(100) WEnd Func _Exit() _WinAPI_SelectObject($g_hDC, $g_hOldFont) _WinAPI_DeleteObject($g_hFont) _WinAPI_ReleaseDC(0, $g_hDC) _WinAPI_InvalidateRect(0, 0) $g_tRECT = 0 Exit EndFunc ;==>_Exit
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now