FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse header sort change picture
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
xBrowse header sort change picture
Posted: Sat Jan 31, 2009 08:16 PM

At the moment if I change the sort order of xBrowse I use to change the header picture :
oxBrw:LButtonDown( 1, 61, 0 )
oxBrw:LButtonUp( 1, 61, 0 )
to simulate a click on the header.
Sure there is a better way.
Thanks in advance
Otto

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse header sort change picture
Posted: Sun Feb 01, 2009 10:54 PM

Hello Otto,

can You explain a bit more in detail, what You want to do ?
There are many possible ways, to change the sort order of the columns :
On Button-action, move the columns with the mouse,
swap columns with mouse-click on a header, right mouse-click inside a data-area and more ...
Just like the text of the header, You can change the bitmap as well on any action.
There is no header-click necessary.
I have done some solutions, but I don't know what to use for Your application.

Regards
Uwe :lol:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse header sort change picture
Posted: Mon Feb 02, 2009 07:54 AM

Hello Uwe,
thank you for your answer.
This is what I want to do:
I delete a record โ€“
then I refresh() the xbrowse โ€“
after the xbrowse gets focus again I want that the sort order is on column 1.
The bitmap must be changed that column 1 is selected.
Thanks in advance
Otto

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse header sort change picture
Posted: Mon Feb 02, 2009 02:24 PM
Hello Otto,

I included the header-painting inside the delete-button-action
It is just the basics, to give You a idea, much more fine-tuning is possible.
There could be a test, if the database contains no deleted record < recall >,
change back to green and so on.
A solution could be, a index on deleted records.
In this case, using the delete-button for delete or recall, You only need to test the 1. Record :

A function could include something like that :
FUNCTION TEST_DEL()
local lDel := .F.
local nOldOrder := INDEXORD()
local nOldrecord := RECNO()

DBSELECTAREA(1)
Net_RLock( 1, 1 )
IF DELETED()
      Net_Recall( 1, 1 )
ELSE
      Net_Delete ( 1, 1 )
ENDIF
Net_ULock()

DBSETORDER( 2 ) // index on deleted
DBGOTOP()
IF deleted()
      lDel = .T.
ENDIF
DBSETORDER( nOldORDER )
DBGOTO( nOldrecord )

RETURN( lDel )


I think You want the header marked, if the database has any deleded records included ?

....
....

// 1. Column
// -------------
oCol := oLbx1:AddCol()
oCol:AddResource( "Green" )
oCol:bStrData := { || (1)->Last}
oCol:cHeader  := "Last"
oCol:cFooter  := "Last"
oCol:nHeadBmpNo := 1

// 2. Column ( Indexed )
// --------------------------
oCol := oLbx1:AddCol()
oCol:AddResource( "Green" )
oCol:AddResource( "Red" )
oCol:bStrData  := { || (1)->First}
oCol:cHeader   := "First"
oCol:cFooter  := "First"
oCol:bBmpData := {|| IIF( deleted(), 2, 1 ) }
oCol:nHeadBmpNo := 1 

// 3. Column
// ------------
oCol := oLbx1:AddCol()
oCol:AddResource( "Green" )
oCol:bStrData := { || (1)->City}
oCol:cHeader  := "City"
oCol:cFooter  := "City"
oCol:nHeadBmpNo := 1
....
....

// Use Your delete-function or include < TEST_DEL() >

// REDEFINE BUTTONBMP oBtn7  ID 70 OF oDlg ;
// ACTION ( IIF( TEST_DEL() = .T., ;  
//      ( oLbx1:SwapCols( 1, 2 ), ;   // Bring selected col 2 ( indexed ) to 1
//        oLbx1:GoLeftMost(), ;         // Go to 1. Col ( indexed )
//        oLbx1:aCols[1]:nHeadBmpNo := 2 ), ; // Red BMP from Col-resource
//      oLbx1:aCols[1]:nHeadBmpNo := 1 ), ; // Green BMP from Col-resource
//      oLbx1:Refresh() ) ;
// BITMAP "Delete" PROMPT "       &Delete" TEXTRIGHT
// oBtn7:cToolTip =  { "Delete" + CRLF + ;
// "a Record","Record-Delete", 1, CLR_BLACK, 14089979 }

// If TEST_DEL() = .F., reset the swapt columns to the original positon with a Green BMP.

REDEFINE BUTTONBMP oBtn7  ID 70 OF oDlg ;
ACTION ( DB_SET(), ;   // Delete and Recall-function
      oLbx1:SwapCols( 1, 2 ), ;   // Bring selected col 2 ( indexed ) to 1
      oLbx1:GoLeftMost(), ;         // Go to 1. Col ( indexed )
      oLbx1:aCols[1]:nHeadBmpNo := 2, ; // Red BMP from Col-resource
      oLbx1:Refresh() ) ;
BITMAP "Delete" PROMPT "       &Delete" TEXTRIGHT
oBtn7:cToolTip =  { "Delete" + CRLF + ;
"a Record","Record-Delete", 1, CLR_BLACK, 14089979 }


The basic-view


After deleting


Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion