Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change color of static/edit using: SetTextColor and SetBkMode
#2
This seems to work but is it possible to preserve the transparency of the static control?

Function change_txt_color_on_buttonpress
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Button 0x54032000 0x0 95 80 48 14 "Button"
;4 Edit 0x54231044 0x200 30 10 152 22 ""
;5 Static 0x54000000 0x0 90 40 48 12 "TEST"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4"
str e4="TEST"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
__GdiHandle- t_hbrush
sel message
,case WM_INITDIALOG
,,int backcolor_at_start=0xffffff
,,t_hbrush=CreateSolidBrush(backcolor_at_start)
,,int- col_1;col_1=ColorFromRGB(255 10 120)
,,int- col_2;col_2=ColorFromRGB(0 110 120) ;; NEW COLOR
,case WM_DESTROY
,,t_hbrush.Delete
,case WM_COMMAND goto messages2
,case [WM_CTLCOLORSTATIC,WM_CTLCOLOREDIT] ;; WM_CTLCOLORLISTBOX not used in this example
,,if(lParam=id(4 hDlg))
,,,SetBkMode wParam TRANSPARENT
,,,SetTextColor wParam col_1
,,,ret t_hbrush
,,if(lParam=id(5 hDlg))
,,,SetBkMode wParam TRANSPARENT
,,,SetTextColor wParam col_1
,,,ret t_hbrush
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,,col_1=col_2        
,,RedrawWindow(id(4 hDlg) 0 0 RDW_INVALIDATE) ;; redraw control editfield
,,RedrawWindow(id(5 hDlg) 0 0 RDW_INVALIDATE) ;; redraw control statc
,,ret t_hbrush
ret 1


Messages In This Thread
RE: Change color of static/edit using: SetTextColor and SetBkMode - by r0n - 08-28-2020, 09:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)