Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change background color of editfield on button click
#1
Is it possible to change the background color of an editfield when a button is clicked?
I can make it work on dialog init, but not on button click:


Function Example___on_button_click_change_background_color
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 222 128 "Dialog"
;3 Button 0x54032000 0x0 51 21 122 29 "Make editfield-backrgournd yellow"
;4 Edit 0x54231044 0x200 12 54 199 52 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,int backcolor=0x00ffff
,,int hbrush=CreateSolidBrush(backcolor)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,;; make background of editfield, yellow
ret 1
#2
Need InvalidateRect or RedrawWindow.

Macro Macro3014
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 222 128 "Dialog"
;3 Button 0x54032000 0x0 51 21 122 29 "Make editfield-backrgournd yellow"
;4 Edit 0x54231044 0x200 12 54 199 52 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam

int-- t_edit
int-- t_backcolor
__GdiHandle-- t_hbrush

sel message
,case WM_INITDIALOG
,t_edit=id(4 hDlg)
,
,case WM_CTLCOLOREDIT
,if(t_hbrush and lParam=t_edit)
,,SetBkColor wParam t_backcolor ;;text background
,,ret t_hbrush ;;other background
,
,case WM_DESTROY
,t_hbrush.Delete
,
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,;make background of editfield, yellow
,t_backcolor=0x00ffff
,t_hbrush.Delete
,t_hbrush=CreateSolidBrush(t_backcolor)
,InvalidateRect t_edit 0 0
ret 1
#3
Thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)