Page 1 of 1
xBrowser: How to repaint the header
Posted: Sun Nov 11, 2007 9:50 pm
by Otto
If I change nHeadBmpNo how do I repaint the header?
oCol:bLClickHeader := {|r,c,f,o| IIF( oCol:nHeadBmpNo = 2, oCol:nHeadBmpNo := 1 ,oCol:nHeadBmpNo := 2 ) )) }
PaintHeader??
Thanks in advance
Otto
Posted: Mon Nov 12, 2007 12:41 am
by ShumingWang
for nFor := 1 TO 4
obrow:aCols[nFor]:AddBmpHandle( obrow:hBmpSortAsc )
obrow:aCols[nFor]:AddBmpHandle( obrow:hBmpSortdes )
obrow:aCols[nFor]:nHeadBmpAlign := AL_RIGHT
if nfor>1;obrow:aCols[nFor]:nHeadBmpNo := -1; end
obrow:aCols[nFor]:bLClickHeader := {|r,c,f,o| SortSal1( o ) }
next
FUNCTION SortSal1(oCol)
local aCols,cOrder,nFor,nLen
aCols := oCol:oBrw:aCols
cOrder := oCol:cOrder
nAt := oCol:nCreationOrder
nLen := LEN(aCols)
for nFor := 1 to nLen
aCols[ nFor ]:nHeadBmpNo := 0
aCols[ nFor ]:cOrder := ""
next
if cOrder == "" .or. cOrder == "D"
// aData := Asort( aData,,, {|x,y| x[ nAt ] < y[ nAt ] } )
do case
case nAt==1
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by custid"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:custid")}
case nAt==2
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by custm"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:custm")}
case nAt==3
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by sales"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:sales")}
case nAt==4
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by addrc"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:addrc")}
endcase
oCol:cOrder := "A"
oCol:nHeadBmpNo := 1
else
// aData := Asort( aData,,, {|x,y| x[ nAt ] > y[ nAt ] } )
do case
case nAt==1
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by custid DESC"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:custid")}
case nAt==2
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by custm DESC"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:custm")}
case nAt==3
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by sales DESC"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:sales")}
case nAt==4
odb1:cQuery:="select * from custm1 "+if(len(ofcomid)>0,"where comid='"+ofcomid+"'","")+" order by addrc DESC"
odb1:refresh()
obrow:bseek:={|v|odb1:SEEK(v,,"odb1:addrc")}
endcase
oCol:cOrder := "D"
oCol:nHeadBmpNo := 2
endif
oCol:oBrw:Refresh()
return
Regards
Shuming Wang
Posted: Mon Nov 12, 2007 6:34 am
by Otto
Thank you for your help.
The line
oCol:oxBrw:Refresh()
causes an error. I don't find out what is wrong.
Regards,
Otto
Error description: Error BASE/1004 Message not found: TXBRWCOLUMN:OXBRW
Args:
[ 1] = O Object
Stack Calls
===========
Called from: => __ERRRT_SBASE(0)
Called from: => TXBRWCOLUMN:ERROR(172)
Called from: source\rtl\tobject.prg => (b)HBOBJECT(103)
Called from: => TXBRWCOLUMN:MSGNOTFOUND(0)
Called from: => TXBRWCOLUMN:OXBRW(162)
Posted: Mon Nov 12, 2007 6:59 am
by Antonio Linares
Otto,
Try:
oCol:oBrw:Refresh()
Posted: Mon Nov 12, 2007 7:18 am
by Otto
Hello Antonio,
thank you. I see the msgInfo correctly but the changes of the bmp are not visible.
oCol:AddBmpHandle( FwBmpAsc() )
oCol:AddBmpHandle( FwBmpDes() )
oCol:nHeadBmpNo := 1
oCol:bLClickHeader := {|r,c,f,o| IIF( oCol:nHeadBmpNo = 2, (oCol:nHeadBmpNo := 1 ,msginfo(1)),(oCol:nHeadBmpNo := 2,msginfo(2) )),oCol:oBrw:Refresh(),msginfo("test") }
Could you please extend the testxbrw.prg
to show how
oCol:nHeadBmpNo =
should be used.
Suggestion:
I would comment for the standard sample ADS out - for a beginner the error this causes is no so easy to find out.
You should also reindex customer automatically. Otherwise the incremental search gives an error.
Regards,
Otto
Posted: Mon Nov 12, 2007 7:28 am
by Antonio Linares
Otto,
You may use:
METHOD PaintHeader( nRow, nCol, nHeight, lInvert, hDC ) CLASS TXBrwColumn
Posted: Mon Nov 12, 2007 7:35 am
by Otto
METHOD PaintHeader( nRow, nCol, nHeight, lInvert, hDC ) CLASS TXBrwColumn
Isn't this called by HeaderLButtonDown?
METHOD HeaderLButtonDown( nMRow, nMCol, nFlags ) CLASS TXBrwColumn
if ::oBrw:nCaptured == 0 .and. ::oBrw:lAllowColSwapping
::oBrw:oCapCol := Self
::oBrw:nCaptured := 1
::oBrw:Capture()
::PaintHeader( 2, nil, ::oBrw:nHeaderHeight - 3, .t. )
endif
return nil
METHOD PaintHeader( nRow, nCol, nHeight, lInvert, hDC ) CLASS TXBrwColumn
Posted: Mon Nov 12, 2007 7:43 am
by Antonio Linares
Otto,
> Isn't this called by HeaderLButtonDown?
Yes
Posted: Mon Nov 12, 2007 7:50 am
by Otto
But the header does not change.
Posted: Mon Nov 12, 2007 9:03 am
by Antonio Linares
Otto,
In samples\TestXBrw.prg, STATIC FUNCTION Bitmaps( oWnd ):
oCol := oBrw:AddCol()
oCol:AddResource( "CLIP" )
oCol:AddResource( "star" )
oCol:bLClickHeader = { | nMRow, nMCol, nFlags, Self | If( ::nHeadBmpNo == 2, ::nHeadBmpNo := 1, ::nHeadBmpNo := 2 ), ::oBrw:Refresh() }
And add this to TestXBrw.rc:
STAR BITMAP "../bitmaps/16x16/favorite.bmp"
Posted: Mon Nov 12, 2007 9:09 am
by Otto
I did it this way. But the header does not change.
Regards,
Otto
STATIC FUNCTION Bitmaps( oWnd )
local oChild, oBrw, oCol, oFont
local nFor
DEFINE FONT oFont NAME "Arial" SIZE 0, -8 BOLD
DEFINE WINDOW oChild TITLE "Bitmaps on browse and bold font on first column" MDICHILD OF oWnd
oBrw := TXBrowse():New( oWnd )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oCol := oBrw:AddCol()
oCol:AddResource( "CLIP" )
oCol:AddResource( "star" )
oCol:bLClickHeader = { | nMRow, nMCol, nFlags, Self | If( ::nHeadBmpNo == 2, ::nHeadBmpNo := 1, ::nHeadBmpNo := 2 ), ::oBrw:Refresh() }
oCol := oBrw:AddCol()
oCol:AddResource("CLIP")
oCol:cHeader := "CLIP"
oCol:nHeadBmpNo := 1
oCol:nHeadBmpAlign := AL_RIGHT
oCol := oBrw:AddCol()
oCol:bStrData := { || _FIELD->First}
oCol:cHeader := "First"
oCol:oDataFont := oFont
oCol := oBrw:AddCol()
oCol:bStrData := { || _FIELD->Last}
oCol:cHeader := "Last"
oCol := oBrw:AddCol()
oCol:AddResource("GREEN")
oCol:AddResource("RED")
oCol:cHeader := "Married"
oCol:bBmpData := { || iif( _FIELD->Married, 1, 2) }
oCol:bStrData := { || iif( _FIELD->Married, "Yes", "No ")}
oCol:bEditValue := { || _FIELD->Married }
oCol:nDataStyle := oCol:DefStyle( AL_RIGHT, .T.)
oCol:nEditType := EDIT_LISTBOX
oCol:aEditListTxt := { "Yes", "No"}
oCol:aEditListBound := { .t., .f. }
oCol:bOnPostEdit := {|o, v| _FIELD->Married := v }
oBrw:SetRDD()
oBrw:CreateFromCode()
oChild:oClient := oBrw
ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()
oFont:End()
RETURN NIL
Posted: Mon Nov 12, 2007 9:12 am
by Antonio Linares
Otto,
Click on the column to see the bitmap change, and don't forget to modify the RC file
Code: Select all
STATIC FUNCTION Bitmaps( oWnd )
local oChild, oBrw, oCol, oFont
local nFor
DEFINE FONT oFont NAME "Arial" SIZE 0, -8 BOLD
DEFINE WINDOW oChild TITLE "Bitmaps on browse and bold font on first column" MDICHILD OF oWnd
oBrw := TXBrowse():New( oWnd )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:lColDividerComplete := .t.
oCol := oBrw:AddCol()
oCol:AddResource( "CLIP" )
oCol:AddResource( "star" )
oCol:bLClickHeader = { | nMRow, nMCol, nFlags, Self | If( ::nHeadBmpNo == 2, ::nHeadBmpNo := 1, ::nHeadBmpNo := 2 ), ::oBrw:Refresh() }
oCol:cHeader := "CLIP"
oCol:nHeadBmpNo := 1
oCol:nHeadBmpAlign := AL_RIGHT
oCol := oBrw:AddCol()
oCol:bStrData := { || _FIELD->First}
oCol:cHeader := "First"
oCol:oDataFont := oFont
oCol := oBrw:AddCol()
oCol:bStrData := { || _FIELD->Last}
oCol:cHeader := "Last"
oCol := oBrw:AddCol()
oCol:AddResource("GREEN")
oCol:AddResource("RED")
oCol:cHeader := "Married"
oCol:bBmpData := { || iif( _FIELD->Married, 1, 2) }
oCol:bStrData := { || iif( _FIELD->Married, "Yes", "No ")}
oCol:bEditValue := { || _FIELD->Married }
oCol:nDataStyle := oCol:DefStyle( AL_RIGHT, .T.)
oCol:nEditType := EDIT_LISTBOX
oCol:aEditListTxt := { "Yes", "No"}
oCol:aEditListBound := { .t., .f. }
oCol:bOnPostEdit := {|o, v| _FIELD->Married := v }
oBrw:SetRDD()
oBrw:CreateFromCode()
oChild:oClient := oBrw
ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()
oFont:End()
RETURN NIL
Posted: Mon Nov 12, 2007 10:25 am
by Otto
Antonio, thank you. Now the bmp changes.
Best regards,
Otto