primo
16-12-2016, 16:49
i was playing with CreateFont, trying different values for it to affect fonts in TextBox
http://winapi.freetechsecrets.com/win32/WIN32CreateFont.htm
some times we need to display other than English words so we should use a charset for that language look :
https://www.powerbasic.com/help/pbcc/font_new_statement.htm
if we install Greek and then trying to type inside the text box we get gibberish characters if the CHARSET = 0, but if we change it to CHARSET = 161 then we can type Greek inside the TextBox
96289629
the next code display bold and big chars, it is very thick FW_BOLD = 700 , also it is very wide (stretched)
the -18 (height) : if we write it as 18 the chars have some chaos.
i think we can't affect specific words in the TextBox. for affecting specific words we need rich edit control. but i may be wrong regarding the TextBox.
as you can see the CreateFont is complex but it is useful if we want to try more options for the fonts
USES "UI"
Begin ControlID
%ID_TextBox1
%ID_TextBox2
End ControlID
function TBMain()
Dim hDlg, hFont As Long
Dialog New 0, "TextBox experiments", -1, -1, 500, 400, _
%WS_DLGFRAME OR %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU, _
0 TO hDlg
Control Add Textbox , hDlg, %ID_TextBox1, "Text box: read only" , 5, 10, 185, 15, %WS_BORDER Or %WS_TABSTOP Or %ES_READONLY , %WS_EX_CLIENTEDGE
Control Add Textbox , hDlg, %ID_TextBox2, "Oki" , 5, 25, 450, 310, %WS_BORDER Or _
%WS_TABSTOP OR _
%ES_WANTRETURN OR _
%ES_MULTILINE OR _
%ES_AUTOHSCROLL OR _
%ES_AUTOVSCROLL OR _
%WS_VSCROLL OR _
%WS_HSCROLL
Integer FW_BOLD, CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH
FW_BOLD = 700: CHARSET = 0: OUT_DEFAULT_PRECIS =0:CLIP_DEFAULT_PRECIS =0:DEFAULT_QUALITY=0: DEFAULT_PITCH=0
hfont = CreateFont(-18, 30, 0, 0, FW_BOLD, FALSE,_
FALSE, FALSE, CHARSET, OUT_DEFAULT_PRECIS,_
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH,"Arial")
Control Set Color hDlg, %ID_TextBox2, Rgb(0,0,255), Rgb(200,255,200)
Control Send hDlg,%ID_TextBox2, %WM_SETFONT, hFont, 0
Control Append Text hDlg, %ID_TextBox2, $CRLF & $CRLF & "to be or not to be" & $CRLF
'---Show dialog in MODAL
DIALOG SHOW MODAL hDlg, call dlgCallback
end function
callback function dlgCallback() as long
select case cbMsg
case %WM_CLOSE
end select
end function
http://winapi.freetechsecrets.com/win32/WIN32CreateFont.htm
some times we need to display other than English words so we should use a charset for that language look :
https://www.powerbasic.com/help/pbcc/font_new_statement.htm
if we install Greek and then trying to type inside the text box we get gibberish characters if the CHARSET = 0, but if we change it to CHARSET = 161 then we can type Greek inside the TextBox
96289629
the next code display bold and big chars, it is very thick FW_BOLD = 700 , also it is very wide (stretched)
the -18 (height) : if we write it as 18 the chars have some chaos.
i think we can't affect specific words in the TextBox. for affecting specific words we need rich edit control. but i may be wrong regarding the TextBox.
as you can see the CreateFont is complex but it is useful if we want to try more options for the fonts
USES "UI"
Begin ControlID
%ID_TextBox1
%ID_TextBox2
End ControlID
function TBMain()
Dim hDlg, hFont As Long
Dialog New 0, "TextBox experiments", -1, -1, 500, 400, _
%WS_DLGFRAME OR %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU, _
0 TO hDlg
Control Add Textbox , hDlg, %ID_TextBox1, "Text box: read only" , 5, 10, 185, 15, %WS_BORDER Or %WS_TABSTOP Or %ES_READONLY , %WS_EX_CLIENTEDGE
Control Add Textbox , hDlg, %ID_TextBox2, "Oki" , 5, 25, 450, 310, %WS_BORDER Or _
%WS_TABSTOP OR _
%ES_WANTRETURN OR _
%ES_MULTILINE OR _
%ES_AUTOHSCROLL OR _
%ES_AUTOVSCROLL OR _
%WS_VSCROLL OR _
%WS_HSCROLL
Integer FW_BOLD, CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH
FW_BOLD = 700: CHARSET = 0: OUT_DEFAULT_PRECIS =0:CLIP_DEFAULT_PRECIS =0:DEFAULT_QUALITY=0: DEFAULT_PITCH=0
hfont = CreateFont(-18, 30, 0, 0, FW_BOLD, FALSE,_
FALSE, FALSE, CHARSET, OUT_DEFAULT_PRECIS,_
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH,"Arial")
Control Set Color hDlg, %ID_TextBox2, Rgb(0,0,255), Rgb(200,255,200)
Control Send hDlg,%ID_TextBox2, %WM_SETFONT, hFont, 0
Control Append Text hDlg, %ID_TextBox2, $CRLF & $CRLF & "to be or not to be" & $CRLF
'---Show dialog in MODAL
DIALOG SHOW MODAL hDlg, call dlgCallback
end function
callback function dlgCallback() as long
select case cbMsg
case %WM_CLOSE
end select
end function