xBrowser: How to repaint the header

xBrowser: How to repaint the header

Postby Otto » Sun Nov 11, 2007 9:50 pm

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
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Postby ShumingWang » Mon Nov 12, 2007 12:41 am

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
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby Otto » Mon Nov 12, 2007 6:34 am

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)
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Nov 12, 2007 6:59 am

Otto,

Try:

oCol:oBrw:Refresh()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Mon Nov 12, 2007 7:18 am

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
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Nov 12, 2007 7:28 am

Otto,

You may use:
METHOD PaintHeader( nRow, nCol, nHeight, lInvert, hDC ) CLASS TXBrwColumn
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Mon Nov 12, 2007 7:35 am

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
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Nov 12, 2007 7:43 am

Otto,

> Isn't this called by HeaderLButtonDown?

Yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Mon Nov 12, 2007 7:50 am

But the header does not change.

Image
Image
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Nov 12, 2007 9:03 am

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"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Mon Nov 12, 2007 9:09 am

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
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Mon Nov 12, 2007 9:12 am

Otto,

Click on the column to see the bitmap change, and don't forget to modify the RC file
Code: Select all  Expand view
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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Mon Nov 12, 2007 10:25 am

Antonio, thank you. Now the bmp changes.
Best regards,
Otto
User avatar
Otto
 
Posts: 6313
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], karinha and 81 guests