Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MultiLine ListBox
#9
I managed to color items with which begin with a square bracket: "["
But is it also possible to style it differently regarding it's font size and style (bold)?
In other words, items that begin with a square bracket also get styled: bold.

I assume the function must have an array added like "t_act" but called "t_style" or something like that?
But it would also mean you have to modifying the function "DT_LbCbOwnerDraw" would take to much time.

Function lb_color
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 ListBox 0x54230161 0x200 31 14 112 73 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040301 "*" "" "" ""

str controls = "3"
str lb3

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

#sub DlgProc
function# hDlg message wParam lParam

ARRAY(int)-- t_act t_acb
if(DT_LbCbOwnerDraw(hDlg message wParam lParam 0 1 t_act t_acb 0xffff 0x1)) ret 1
sel message
,case WM_INITDIALOG
,,int- dark_orange=ColorFromRGB(180 90 10)
,,int- dark_grey=ColorFromRGB(95 95 95)
,,int- black=ColorFromRGB(0 0 0)
,,int- green=ColorFromRGB(0 153 0)
,,int- red=ColorFromRGB(255 0 0)
,
,,;; DECLARE LISTBOX
,,int lb=id(3 hDlg)
,
,,;; SET FONT
,,__Font-- t_f.Create("Courier" 10 0)
,,t_f.SetDialogFont(hDlg "3")

,,;; ITEMS THAT WILL POPULATE LISTBOX
,,str lb_text="[ test 1 ][][ test 2 ][]test 3[]test 4"
,,
,,;; SET THE COLOR STYLE FOR THE DESIRED ITEMS
,,;; JUST SET IT'S CORRESPONDING 't_act[]' TO THE DESIRED COLOR
,,foreach _s lb_text
,,,str regx="^\["
,,,if(findrx(_s regx)>=0)
,,,,t_act[]=dark_orange
,,,else
,,,,t_act[]=dark_grey

,,;; FILL THE LISTBOX
,,ARRAY(str) a.create(1)        
,,a=lb_text
,,int i
,,for(i 0 a.len) LB_Add lb a[i]

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)