BCX_SET_FONT procedures
Purpose: The BCX_SET_FONT function(syntax 1) will return the handle to a logical font if the function succeeds. The BCX_SET_FONT statement(syntax 2) will set the font in a Control according to the value in the fontface and fontsize arguments.
Syntax 1: Function hFont = BCX_SET_FONT(FontFace$, _ FontSize% _ [, Weight%] _ [, Italic%] _ [, Underline%] _ [, StrikeThru%] _ [, CharacterSet%]) Syntax 2: Statement BCX_SET_FONT(hWnd, _ FontFace$, _ FontSize% _ [, Weight%] _ [, Italic%] _ [, Underline%] _ [, StrikeThru%] _ [, CharacterSet%]) Parameters:
|
BCXFONT Global HFONT handle
The Global HFONT handle BCXFONT can be used to change the application's default font. Any BCX controls created will use the font that is assigned to BCXFONT at that time. Setting BCXFONT to zero will use GetStockObject(DEFAULT_GUI_FONT) which is the default.
Example: BCXFONT and BCX_SET_FONT
GUI "ButtonTest",PIXELS GLOBAL form1 AS HWND GLOBAL fnts[20] AS HFONT SET fontname[] AS PCHAR "Courier New","Comic Sans MS","Lucida Sans","Verdana" END SET SUB FORMLOAD DIM RAW i,ii form1 = BCX_FORM("Button AutoSize Test",0,0,840,550) FOR i = 0 TO 3 FOR ii = 0 TO 4 fnts[i*ii] = BCX_SET_FONT(fontname$[i],8+(2*ii)) BCXFONT = fnts[i*ii] BCX_BUTTON(fontname$[i] + STR$(8+(2*ii)),form1,0,10+i*220,10+ii*100) NEXT NEXT BCX_ButtonOld("This button uses the default font and the old sizing method",form1,0,10,10+5*90) BCXFONT = 0 BCX_BUTTON("This button uses the default font and the new sizing method",form1,0,10,40+5*90) CENTER(form1) SHOW(form1) END SUB BEGIN EVENTS SELECT CASE CBMSG CASE WM_CLOSE FOR integer i = 0 TO 19 DeleteObject(fnts[i]) NEXT i END SELECT END EVENTS FUNCTION BCX_ButtonOld OPTIONAL(Text$, _ hWnd AS HWND, _ id, _ X, _ Y, _ W=0, _ H=0, _ Style=0, _ Exstyle=-1) AS HWND $CCODE if(!Style) { Style=WS_CHILD | WS_VISIBLE | BS_MULTILINE | BS_PUSHBUTTON | WS_TABSTOP; } if(Exstyle==-1) { Exstyle=WS_EX_STATICEDGE; } HWND A = CreateWindowEx(Exstyle,"button",Text,Style, X*BCX_ScaleX, Y*BCX_ScaleY, W*BCX_ScaleX, H*BCX_ScaleY, hWnd,(HMENU)id,BCX_hInstance,NULL); SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0)); if(W==0) { HDC hdc=GetDC(A); SIZE sz; GetTextExtentPoint32(hdc,Text,strlen(Text),&sz); ReleaseDC(A,hdc); MoveWindow(A,X*BCX_ScaleX,Y*BCX_ScaleY,sz.cx+(sz.cx*0.5),sz.cy+(sz.cy*0.32),TRUE); } $CCODE FUNCTION = A END FUNCTION
For other examples of the BCX_SET_FONT statement see FontDemo.bas and FontDialogDemo.bas .