Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting the font of text
#1
I have looked on the forum and I can not seem to find any post about it. Is there a way to change the font in a multiline edit field so that some text is Bold and underlined while other text is regular?

Example:
   
#2
Function GetRTF_Test
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str rea3
rea3="&$desktop$\Document.rtf" ;;a file created in Wordpad
if(!ShowDialog("GetRTF_Test" &GetRTF_Test &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 RichEdit20A 0x54233044 0x200 6 6 96 48 ""
;4 Button 0x54032000 0x0 6 64 48 14 "Button"
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#3
Create such text in wordpad or word and save as rtf document. In qm, create rich edit control and assign path of the file to the variable. Add & at the beginning.
#4
This works but every time I want to use it I would have to create something in WordPad and move it over to my dialog. Is there a way that I can do it just using QM?
#5
also found this
Function dlg_rich_text
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

def EN_LINK 0x070b
def ENM_LINK 0x04000000
def CFM_COLOR 0x40000000
def CFM_LINK 0x20
def CFE_LINK 0x00000020
def SCF_SELECTION 1
type CHARFORMAT2 cbSize dwMask dwEffects yHeight yOffset crTextColor !bCharSet !bPitchAndFamily !szFaceName[LF_FACESIZE] @wWeight @sSpacing crBackColor lcid dwReserved @sStyle @wKerning !bUnderlineType !bAnimation !bRevAuthor !bReserved1
type ENLINK NMHDR'nmhdr msg wParam lParam CHARRANGE'chrg

str controls = "3"
str rea3
rea3="simple text red text link[]"
if(!ShowDialog("dlg_rich_text" &dlg_rich_text &controls)) ret

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 223 135 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 RichEdit20A 0x54233044 0x200 4 4 216 104 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "*" ""

ret
;messages
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,
,int re=id(3 hDlg)
,CHARRANGE cr
,CHARFORMAT2 cf.cbSize=sizeof(CHARFORMAT2)
,;red text
,cr.cpMin=12
,cr.cpMax=20
,SendMessage(re EM_EXSETSEL 0 &cr)
,cf.dwMask=CFM_COLOR
,cf.crTextColor=0xff
,SendMessage(re EM_SETCHARFORMAT SCF_SELECTION &cf)
,;link
,cr.cpMin=21
,cr.cpMax=25
,SendMessage(re EM_EXSETSEL 0 &cr)
,cf.dwMask=CFM_LINK
,cf.dwEffects=CFE_LINK
,SendMessage(re EM_SETCHARFORMAT SCF_SELECTION &cf)
,;enable events
,SendMessage(re EM_SETEVENTMASK 0 ENM_LINK)
,;remove selection
,SendMessage(re EM_SETSEL 0 0)
,
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
;messages3
NMHDR* n=+lParam
sel n.code
,case EN_LINK
,ENLINK* el=+n
,if(el.msg=WM_LBUTTONUP)
,,out "a link clicked at %i-%i" el.chrg.cpMin el.chrg.cpMax
#6
Perfect again I do not know how you keep doing it but it seams to be exactly what I need. I will have to take a couple of days to understand it but I can see many uses for it already.

Thank You
#7
This is so fantastic I can not believe it. I have found a way to use it with strings or getwintext.
str controls = "3"
str rea3
/ this
str s.getwintext(id(3 win("Dialog2" "#32770")))
/ or this
str s = "Hello all how are you today"
rea3=s

Is there a way to do bold text and underlined text?
#8
Yes, read CHARFORMAT2 help in msdn library.
#9
Is there a way to have the text in rea3 change based on case 4? I am trying to not have to do my multipage dialog like you did in Dialog60 SysTabControl32 at the same time I want to be able to use the different font colors.

;messages2
sel wParam
,case 4
,rea3="Hello and Hello and Hello"
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1


Forum Jump:


Users browsing this thread: 2 Guest(s)