Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two Questions for QMGRID cell color paint
#4
sorry didn't see your last response
 here you go. I have simplified the dialogs some

Function GridColorSpecificCellOnLoad
Code:
Copy      Help
,_s=
,;rabbit,10,100
,;tiger,20,200
,;horse,30,300
,;rabbit,40,400

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 300 168 "Dialog" "4"
;3 QM_Grid 0x56031041 0x200 12 12 276 122 "0x0,0,0,0x4,0x0[]A,,,[]B,,,[]C,,,"
;1 Button 0x54030001 0x4 176 144 48 14 "OK"
;2 Button 0x54030000 0x4 232 144 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam

DlgGrid grid.Init(hDlg 3)

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

;messages3
NMLVCUSTOMDRAW* cd=+lParam
sel cd.nmcd.dwDrawStage
,case CDDS_PREPAINT _i=CDRF_NOTIFYITEMDRAW ;;yes, notify me to draw items
,case CDDS_ITEMPREPAINT _i=CDRF_NOTIFYSUBITEMDRAW ;;draw subitems
,case CDDS_ITEMPREPAINT|CDDS_SUBITEM
,int row=cd.nmcd.dwItemSpec
,str cell=grid.CellGet(row 0)
,,sel cell
,,,case "rabbit"
,,,if(cd.iSubItem=0) ;;first cell of row rabbit
,,,,cd.clrTextBk=0x0000FF;;; red text background
,,,else
,,,,cd.clrTextBk=0xFFFFFF;;; white text background
,,,case "tiger" 
,,,if(cd.iSubItem=0)    ;; first cell of row tiger
,,,,cd.clrTextBk=0xFF0000;;;  blue text background
,,,,cd.clrText=0xFFFFFF;;; white text
,,,else
,,,,cd.clrTextBk=0xFFFFFF;;; white text background
,,,,cd.clrText=0x000000;;; black text
,,,case "horse"
,,,if(cd.iSubItem=0) ;; first cell of row horse
,,,,cd.clrTextBk=0x00FF00;;;  green text background
,,,else
,,,,cd.clrTextBk=0xFFFFFF;;; white text background            
ret DT_Ret(hDlg _i)


Function GridColorSpecificCellOnCheck
Code:
Copy      Help
,_s=
,;rabbit,10,100
,;tiger,20,200
,;horse,30,300
,;rabbit,40,400

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 300 168 "Dialog" "4"
;3 QM_Grid 0x56031041 0x200 12 12 276 122 "0x20,0,0,0x4,0x0[]A,,,[]B,,,[]C,,,"
;1 Button 0x54030001 0x4 176 144 48 14 "OK"
;2 Button 0x54030000 0x4 232 144 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam

DlgGrid grid.Init(hDlg 3)

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

;messages3
NMLVCUSTOMDRAW* cd=+lParam
sel cd.nmcd.dwDrawStage
,case CDDS_PREPAINT _i=CDRF_NOTIFYITEMDRAW ;;yes, notify me to draw items
,case CDDS_ITEMPREPAINT _i=CDRF_NOTIFYSUBITEMDRAW ;;draw subitems
,case CDDS_ITEMPREPAINT|CDDS_SUBITEM
,int row=cd.nmcd.dwItemSpec
,if(grid.RowIsChecked(row)) 
,,str cell=grid.CellGet(row 0)
,,sel cell
,,,case "rabbit"
,,,if(cd.iSubItem=0) ;;first cell of row rabbit
,,,,cd.clrTextBk=0x0000FF;;; red text background
,,,else
,,,,cd.clrTextBk=0xFFFFFF;;; white text background
,,,case "tiger" 
,,,if(cd.iSubItem=0)    ;; first cell of row tiger
,,,,cd.clrTextBk=0xFF0000;;;  blue text background
,,,,cd.clrText=0xFFFFFF;;; white text
,,,else
,,,,cd.clrTextBk=0xFFFFFF;;; white text background
,,,,cd.clrText=0x000000;;; black text
,,,case "horse"
,,,if(cd.iSubItem=0) ;; first cell of row horse
,,,,cd.clrTextBk=0x00FF00;;;  green text background
,,,else
,,,,cd.clrTextBk=0xFFFFFF;;; white text background            
ret DT_Ret(hDlg _i)


Messages In This Thread
RE: Two Questions for QMGRID cell color paint - by Kevin - 08-21-2019, 02:55 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)