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: FunctionhFont = BCX_SET_FONT(FontFace AS STRING, _ FontSize AS INTEGER _ [, Weight AS INTEGER] _ [, Italic AS INTEGER] _ [, Underline AS INTEGER] _ [, StrikeThru AS INTEGER] _ [, CharacterSet AS INTEGER] _ [, Rotation AS INTEGER]) Syntax 2: Statement BCX_SET_FONT(HndlWnd AS HWND, _ FontFace AS STRING, _ FontSize AS INTEGER _ [, Weight AS INTEGER] _ [, Italic AS INTEGER] _ [, Underline AS INTEGER] _ [, StrikeThru AS INTEGER] _ [, CharacterSet AS INTEGER] _ [, Rotation AS INTEGER]) Return Value:
Parameters:
|
GUI "BCX_Font_Rotation" SUB FORMLOAD DIM Form1 AS CONTROL DIM Label_1 AS CONTROL Form1 = BCX_FORM("BCX Font Rotation", 0, 0, 200, 200) Label_1 = BCX_LABEL("Hey Look, I'm Twisted!", Form1, 80, 55, 5, 215, 250, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE) BCX_SET_FONT(Label_1, "Tahoma", 14, FW_BOLD, 1, 0, 0, 0, 450) ' the 450 = 450 TENTHS of a degree = 45 degrees CENTER Form1 SHOW Form1 END SUB BEGIN EVENTS END EVENTS
The BCXFONT handle 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.
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 AS STRING, _ 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