Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coloured text with ShowText
#1
Is it possible to output coloured text with ShowText using a tag coloured string variable, for example : str s=F"<>Word 1<c 255>Word2</c>Word3" ?

Many thanks for any advice.
#2
Only rtf file.
#3
Tags like "<>Word 1<c 255>Word2</c>Word3" are supported by controls of class "QM_DlgInfo", but it is unavailable in exe.

Function Dialog155
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 QM_DlgInfo 0x54000004 0x20000 0 0 224 114 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" "3"

str controls = "3"
str qmdi3
qmdi3="<>Word 1<c 255>Word2</c>Word3"
if(!ShowDialog(dd 0 &controls)) ret
#4
Dear Gintaras,

Many thanks indeed.

It is fine with rtf files, but i is rather impossible to save tag coloured strings to an .rtf file, unlsess I am wrong.

I have already tried class "QM_DlgInfo" as advised in Macro contents marked up in output window and dlg rich edit.
However, I am wondering whether there exists further reference to help files that they could provide further advice.
#5
Or use web browser control and HTML.

Function Dialog156
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 226 114 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""

str controls = "3"
str ax3SHDax3SHD="<html><body>Word 1<font color=red>Word2</font>Word3</body></html>"
if(!ShowDialog(dd 0 &controls)) ret
#6
It is perfect! I can now manage it successfully. Many thanks again and kind regards!
#7
I am sorry, I have one more question: Is it possible to set the font of a controls of class "QM_DlgInfo" control ?

Actually, I managed to change the font, but only of non-coloured characters :

Function Dialog159
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 QM_DlgInfo 0x54000004 0x20000 0 0 224 114 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" "3"

str controls = "3"
str qmdi3
qmdi3="<>Word 1<c 255>Word2</c>Word3[]Word 4<c 255>Word5</c>Word6"

if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,,SendMessage(id(3 hDlg), SCI.SCI_STYLESETFONT ,32, "Courier New")
,,SendMessage(id(3 hDlg), SCI.SCI_STYLESETSIZE ,32, 12)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Finally, this version worked perfectly. However, I am not sure if this is the proper solution :

Function Dialog159
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 QM_DlgInfo 0x54000004 0x20000 0 0 224 114 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" "3"

str controls = "3"
str qmdi3
qmdi3="<>Word 1<c 255>Word2</c>Word3[]Word 4<c 2817792>Word5</c>Word6"

if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,,for _i 0 255
,,,SendMessage(id(3 hDlg), SCI.SCI_STYLESETFONT ,_i, "Courier New")
,,,SendMessage(id(3 hDlg), SCI.SCI_STYLESETSIZE,_i, 12)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

Any advice from you, Gintaras, is mostly welcome and it will be appreciated.
#8
Function QmDlgInfoControlSetFont
Code:
Copy      Help
;/
function hwnd [$fontName] [fontSize]

;Changes font of control of class QM_DlgInfo.
;Call on WM_INITDIALOG. Set control text after.

;hwnd - control handle.
;fontName - font name, or 0 to not change.
;fontSize - font size, or 0 to not change.


int h=hwnd
if(!empty(fontName)) SendMessage(h SCI.SCI_STYLESETFONT 32 fontName)
if(fontSize) SendMessage(h SCI.SCI_STYLESETSIZE 32 fontSize)

;save <code> styles
type __QDISTYLE colText colBack !bold !italic !underline !eol
ARRAY(__QDISTYLE) a.create(32)
int i
for i 1 18
,__QDISTYLE& r=a[i]
,r.colText=SendMessage(h SCI.SCI_STYLEGETFORE i 0)
,r.colBack=SendMessage(h SCI.SCI_STYLEGETBACK i 0)
,r.bold=SendMessage(h SCI.SCI_STYLEGETBOLD i 0)
,r.italic=SendMessage(h SCI.SCI_STYLEGETITALIC i 0)
,r.underline=SendMessage(h SCI.SCI_STYLEGETUNDERLINE i 0)
,r.eol=SendMessage(h SCI.SCI_STYLEGETEOLFILLED i 0)

;set other styles the same as the default style 32. It clears <code> styles etc, that is why we save/restore them.
SendMessage(h SCI.SCI_STYLECLEARALL 0 0)

;restore
for i 1 18
,&r=a[i]
,SendMessage(h SCI.SCI_STYLESETFORE i r.colText)
,SendMessage(h SCI.SCI_STYLESETBACK i r.colBack)
,SendMessage(h SCI.SCI_STYLESETBOLD i r.bold)
,SendMessage(h SCI.SCI_STYLESETITALIC i r.italic)
,SendMessage(h SCI.SCI_STYLESETUNDERLINE i r.underline)
,SendMessage(h SCI.SCI_STYLESETEOLFILLED i r.eol)
SendMessage(h SCI.SCI_STYLESETVISIBLE 31 0)
Macro Macro2487
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 QM_DlgInfo 0x54000004 0x20000 0 0 224 114 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" "3"

str controls = "3"
str qmdi3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,,QmDlgInfoControlSetFont id(3 hDlg) "Courier New" 12
,,
,,;set text after changing font
,,str s="<>Word 1<c 255>Word2</c>Word3[]Word 4<c 255>Word5</c>Word6[]<help>act</help>[]<code>SendMessage(id(3 hDlg), SCI.SCI_STYLESETFONT</code>"
,,s.setwintext(id(3 hDlg))
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#9
Many thanks indeed. Much indebted. It worked perfectly. Best regards. Simos.
#10
I am afraid there exists still an additional question : The vertical scroll bar of QM_DlgInfo class window does not have a right click menu with commands to control the scroll bar (ie. Scroll Here, Top, etc.). Is it likely that one of QM_DlgInfo class item controls has to be used?

Many thanks.
#11
Disable the default popup menu with SCI_USEPOPUP.

Function Dialog164
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 QM_DlgInfo 0x54000000 0x20000 0 0 120 48 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" "3"

str controls = "3"
str qmdi3
qmdi3="1[]2[]3[]4[]5[]6[]7[]8[]9"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) SCI.SCI_USEPOPUP 0 0
,
,case WM_CONTEXTMENU
,sel GetDlgCtrlID(wParam)
,,case 3
,,sel ShowMenu("1 Copy[]2 Paste" hDlg)
,,,case 1 SendMessage wParam SCI.SCI_COPY 0 0
,,,case 2 SendMessage wParam SCI.SCI_PASTE 0 0
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#12
Perfect and genius !


Forum Jump:


Users browsing this thread: 1 Guest(s)