FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
xBrowse
Posted: Wed Sep 14, 2011 05:06 AM

Hi all,

Using a DBF with no index...

Which is the rigth way to programatically delete the current record from a Browse???

oBrw:Delete() does not seem to doit for me...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse
Posted: Wed Sep 14, 2011 07:57 AM

Do you have SET DELETED ON in your code?

Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse
Posted: Wed Sep 14, 2011 11:59 AM
Code (fw): Select all Collapse
( oBrw:cAlias )->( DbDelete() )
oBrw:Refresh()
Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse
Posted: Wed Sep 14, 2011 04:02 PM
Otto wrote:Do you have SET DELETED ON in your code?


Thanks Otto, Yes It's ON

Code (fw): Select all Collapse
( oBrw:cAlias )->( DbDelete() )
oBrw:Refresh()


Thanks Mr. Rao, It worked as I needed after a few changes in my other code...

Amazingly I did not find It's correct use, on a quick lookup... But I knew that you had the right solution, next time I am going to start by reading your post's...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse
Posted: Wed Sep 14, 2011 05:42 PM
After deleting a random row, I get this visual problem now:

I achieve the effect using :bClrStd

Is there a way to refresh the colors of the browse???

.OR.

I tried to avoid this not turning SET DELETED ON, but the row does not appears DISABLED as it should be, and the button in that deleted row still works, and the text is still shown as Non Deleted.

Is there a way to show it disabled????

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse
Posted: Wed Sep 14, 2011 06:25 PM
Bayron,

I achieve the effect using :bClrStd


Please post the code you use for bClrStd, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse
Posted: Wed Sep 14, 2011 06:28 PM
Code (fw): Select all Collapse
:bClrStd  := { || If( Eval( ListVen:bKeyNo,,ListVen ) % 2 == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse
Posted: Wed Sep 14, 2011 08:05 PM

oBrw:KeyNo() returns the OrdKeyNo() as returned by the RDD. Less known is the fact that OrdKeyNo() returns correct serial number only when FILTER is set on ".NOT. DELETED()" when SET DELETED is ON.

So,
USE <dbf>
SET DELETED ON !DELETED()
GO TOP

Then browse as usual.

Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse
Posted: Wed Sep 14, 2011 09:23 PM
Code (fw): Select all Collapse
SET DELETED ON !DELETED()

Does not work on FWH10.2 and xHarbour 1.21...
I also tried:
Code (fw): Select all Collapse
SET DELETED ON
SET FILTER TO !DELETED()


Anyhow, xBrowse is behaven normally...
The problem is that each line is painted before a row is deleted... and when oBrw:Refresh() is called, :bClrStd is not Evaluated and Repainted again...

So if there is not an easy solution ?????? I think I am just going to have to paint a single color in the browse...

Which leads to my next question:

Is there a way to paint the Browse Client Area when the Database is Empty??? Right now is ALL WHITE...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse
Posted: Wed Sep 14, 2011 11:09 PM
Bayron,

Use that FOR ... condition to create the index:

INDEX ON ... FOR ! Deleted() ...

example:
Code (fw): Select all Collapse
      INDEX ON Name TAG "Name" ;
         TO ( cPath + "\Test" ) FOR ! Test->( Deleted() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse
Posted: Thu Sep 15, 2011 02:29 AM

Thanks for taking the time to answer my post, but the problem is not about the Deleted Records, but is that when I delete a record, the color of that row is lost and I get two consecutive rows with the same color....As you can see the above picture...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse
Posted: Thu Sep 15, 2011 03:57 AM
Here is a working sample:
Please adopt this logic to your case.
Code (fw): Select all Collapse
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oFont

   SET DELETED ON

   USE CUSTOMER
   SET FILTER TO !DELETED()
   GO TOP

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 600,400 PIXEL FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      COLUMNS "First", "City", "State", "Salary" ;
      ALIAS 'CUSTOMER' CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrStd    := { || { CLR_BLACK, If( oBrw:KeyNo() % 2 == 0, RGB(224,236,255), RGB(189,211,253) ) } }
      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrw:cAlias)->( BrwDelete( oBrw ) ), nil ) }
   END


   oBrw:CreateFromCode()
   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont


return (0)

//----------------------------------------------------------------------------//

static function BrwDelete( oBrw )

   if DbrLock()
      DELETE
      DbUnlock()
      SKIP
      if ( eof() )
         GO BOTTOM
      endif
      oBrw:Refresh()
   endif

return nil

//----------------------------------------------------------------------------//
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse
Posted: Thu Sep 15, 2011 03:58 AM
FiveWin, One line of code and it's done...


Well Said !!!!
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse
Posted: Thu Sep 15, 2011 04:26 AM
Is there a way to paint the Browse Client Area when the Database is Empty??? Right now is ALL WHITE...

As of now, no.
You may try having one blank record to get the effect you want.
Regards



G. N. Rao.

Hyderabad, India
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: xBrowse
Posted: Thu Sep 15, 2011 04:29 AM
Thanks for your answer, I do use basicly the same logic, but as I said before
The problem is not about the Deleted Records, but is that when I delete a record, the color of that row is lost and I get two consecutive rows with the same color....As you can see the above picture...


I think the problem is with the painting, when I use oBrw:Refresh() :bClrStd is not Evaluated and Repainted again...

I am just going to set the browse records on a single color... to avoid all of the trouble...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...