I am trying to do a xBrowse with a column with checkboxes and header with another check box to check/uncheck all. The code is pretty simple:
- Code: Select all Expand view RUN
- REDEFINE XBROWSE oBrwTipiDoc ID 4009 STYLE 2015
oBrwTipiDoc:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrwTipiDoc:lFastEdit := .T.
ADD COLUMN TO oBrwTipiDoc ARRAY TITLE "" ELEMENT 1 EDITABLE
ADD COLUMN TO oBrwTipiDoc ARRAY TITLE "" ELEMENT 2
ADD COLUMN TO oBrwTipiDoc ARRAY TITLE "" ELEMENT 3
with object oBrwTipiDoc:aCols[1]
:SetCheck( GetCheckBoxes(oDlg), .t.)
//:nEditType := EDIT_BUTTON
//:bEditBlock := {|r,c,o,k| oBrwTipiDoc:aArrayData[oBrwTipiDoc:nRowSel,1] := !oBrwTipiDoc:aArrayData[oBrwTipiDoc:nRowSel,1] }
//:bEditValue := {|r,c,o,k| oBrwTipiDoc:aArrayData[oBrwTipiDoc:nRowSel,1] := !oBrwTipiDoc:aArrayData[oBrwTipiDoc:nRowSel,1] }
:nHeadBmpNo := { || GetHeadBmpId(oBrwTipiDoc:aArrayData) }
end
oBrwTipiDoc:SetArray( {;
{.T.,"OF","Ordine fornitore"},;
{.T.,"SR","Scarti per rottira"},;
{.T.,"SL","Scarti per lavorazione"};
})
and the GetHeadBmpId is
- Code: Select all Expand view RUN
- func GetHeadBmpId(aArrayData)
if aScan(aArrayData, {|x| !x[1] })==0
return 1
endif
if aScan(aArrayData, {|x| x[1] })==0
return 2
endif
return 3
So if there are all checked shows 1-checked, it there are none checked shows 2-unchecked other cases shows 3-indefinite. My problem is that If I change a check box, with double click the header is not updated until the next render.
I did an example gif:
Can I fix it?
PS. There is a possibility to check/uncheck with one click without select the row?
PPS. The GetCheckBoxes is the one I posted some time ago:
- Code: Select all Expand view RUN
- #define DFC_BUTTON 4
#define DFCS_BUTTONCHECK 0x0000
#define DFCS_CHECKED 0x0400
#define DFCS_INACTIVE 0x0100
#define BP_CHECKBOX 3
#define CBS_UNCHECKEDNORMAL 1
#define CBS_CHECKEDNORMAL 5
#define CBS_MIXEDNORMAL 9
function GetCheckBoxes(oWnd)
LOCAL hDCMem, hBmpMem := {Nil,Nil,Nil},i, tmp
LOCAL FCStates := {DFCS_BUTTONCHECK,nOr(DFCS_BUTTONCHECK,DFCS_CHECKED),nOr(DFCS_BUTTONCHECK,DFCS_INACTIVE)}
LOCAL TMStates := {CBS_CHECKEDNORMAL,CBS_UNCHECKEDNORMAL,CBS_MIXEDNORMAL}
LOCAL oTheme := 0
if IsAppThemed()
oTheme = C5_OpenThemeData(oWnd:hWnd,"BUTTON")
endif
for i:=1 to 3
hDCMem := CreateCompatibleDC( oWnd:GetDC() )
hBmpMem[i] := CreateCompatibleBitmap( oWnd:GetDC(), 16, 16 )
tmp := SelectObject( hDCMem, hBmpMem[i] )
FillRect( hDCMem,{0,0,16,16}, GetStockObject( 0 ) )
if oTheme != 0
C5_DrawThemeBackground(oTheme, hDCMem, BP_CHECKBOX,TMStates[i],{1,1,15,15})
else
DrawFrameControl(hDCMem,{1,1,15,15}, DFC_BUTTON,FCStates[i])
endif
SelectObject( hDCMem, tmp )
DeleteDC( hDCMem )
next
if oTheme!=0
C5_CloseThemeData(oTheme)
endif
return hBmpMem
PPPS: sorry for italian messages