Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog control background color
#1
I would appreciate any advice on the way to change the background color of dialog control "5" (static) in the following example :

Function MyStopWDialog
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;Housekeeping :Toolbar vs Dialog, minimizing and closing with apps.htm

;BEGIN DIALOG
;0 "" 0x90C80840 0x0 0 0 223 135 "Dialog"
;5 Static 0x54000202 0x0 0 0 26 12 "9999"
;END DIALOG
;DIALOG EDITOR: "" 0x203000C "" "" ""

ret
;messages

sel message
,case WM_INITDIALOG
,,__Font-- f
,,f.Create("Courier New" 10 0)
,,f.SetDialogFont(hDlg "5")
,,f.SetDialogFontColor(hDlg 0xff0000 "5")
,,SetTimer hDlg 0 1000 0


,case WM_TIMER
;,,STWc=0 : Initialise - Reset
;,,STWc=1 : Start
;,,STWc=2 : Stop
,,if STWc
,,,if STWc=1
,,,,int t1=GetDlgItemInt(hDlg 5 0 0)
,,,,t1+1
,,,,SetDlgItemInt(hDlg 5 t1 0)
,,,else
,,,,ret
,,else
,,,t1=0
,,,SetDlgItemInt(hDlg 5 t1 0)
,,,SetEvent(t_hevent)

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
ret 1
#2
Thanks, if anybody has tried to propose a suggestion. I attach bellow my approach which it worked fine with me :

Function MyStopWDialog
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;Housekeeping :Toolbar vs Dialog, minimizing and closing with apps.htm

;BEGIN DIALOG
;0 "" 0x90C80840 0x0 0 0 223 135 "Dialog"
;5 Static 0x54000202 0x0 0 0 26 12 "9999"
;END DIALOG
;DIALOG EDITOR: "" 0x203000C "" "" ""

ret
;messages
;out "%x" message

int textcolor=0xff
int backcolor=0x00ff00
int-- hbrush

sel message
,case WM_INITDIALOG
,,__Font-- f
,,f.Create("Courier New" 10 0)
,,f.SetDialogFont(hDlg "5")
;,,f.SetDialogFontColor(hDlg 0xff0000 "5")
,,SetTimer hDlg 0 1000 0
,,hbrush=CreateSolidBrush(backcolor)


,case WM_TIMER
;,,STWc=0 : Initialise - Reset
;,,STWc=1 : Start
;,,STWc=2 : Stop
,,if STWc
,,,if STWc=1
,,,,int t1=GetDlgItemInt(hDlg 5 0 0)
,,,,t1+1
,,,,SetDlgItemInt(hDlg 5 t1 0)
,,,else
,,,,ret
,,else
,,,t1=0
,,,SetDlgItemInt(hDlg 5 t1 0)
,,,SetEvent(t_hevent)

,case WM_CTLCOLORSTATIC
,if(lParam=id(5 hDlg))
,,SetTextColor wParam textcolor ;;text
,,SetBkMode wParam TRANSPARENT
,,ret hbrush ;;background

,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
ret 1
#3
tip.
brushes and other GDI objects must be deleted. Call DeleteObject on WM_DESTROY, or declare it as __GdiHandle-- hbrush (then it will be deleted when thread ends).
#4
Many thanks for this useful tip.


Forum Jump:


Users browsing this thread: 1 Guest(s)