Page 1 of 1

Help for a XBrowse (SOLVED THANKS UKOENIG)

PostPosted: Sat Sep 14, 2019 4:47 pm
by Armando
Hello:

In an Xbrowse I usually do the following for a logical field
Code: Select all  Expand view

                WITH OBJECT :aCols[09]
                    :SetCheck( { "SI16","NO16" } )
                END
 


but what should I do for a decimal field ?

Regards

Re: Help for a XBrowse

PostPosted: Sun Sep 15, 2019 8:59 am
by ukoenig
Armando,

In an Xbrowse I usually do the following for a logical field

WITH OBJECT :aCols[09]
:SetCheck( { "SI16","NO16" } )
END

but what should I do for a decimal field ?


I don't know exactly what You need
just a sample ( any fieldtype )

// numeric
:aCols[ 4 ]:nEditType := EDIT_BUTTON
:aCols[ 4 ]:addbmpfile( c_path1 + "Checkon.bmp" ) // from Disk
:aCols[ 4 ]:addbmpfile( c_path1 + "Checkoff.bmp" ) // from Disk
:aCols[ 4 ]:bBmpData := {|| IIF( oCust:Age < 30, 1, 2 ) }


Image

Code: Select all  Expand view

// numeric
    :aCols[ 4 ]:nEditType     := EDIT_BUTTON
    :aCols[ 4 ]:addbmpfile( c_path1 + "Checkon.bmp" ) // from Disk
    :aCols[ 4 ]:addbmpfile( c_path1 + "Checkoff.bmp" ) // from Disk
    :aCols[ 4 ]:bBmpData := {|| IIF( oCust:Age < 30, 1, 2 ) }
    :aCols[ 4 ]:bAlphaLevel := { || IF( ( oBrw:cAlias )->( Deleted() ) , 60, 255 ) }
    :aCols[ 4 ]:bEditBlock    := { | nRow, nCol, oCol, nKey | ;
           Retvalue := MYCELLDLG( oBrw, nRow, nCol, oCol, nKey, ;
           aItems3, aImages, 0, oListFont, 16769217, oFont, oCust ), ;
           IIF( Retvalue <> NIL, ( oCust:Age := VAL(Retvalue), oBrw:RefreshCurrent(), ;
                 oBrw:SelectCol(5) ), NIL ) } // next column
   :aCols[ 4 ]:bClrStd := { || { If( oCust:Age > 30, CLR_HRED, CLR_BLACK ), CLR_WHITE } }

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

FUNCTION MYCELLDLG( oBrw, nRow, nCol, oCol, nKey, aItems, aImages, nSpace, oListFont, nColor, oFont, oCust )
LOCAL oDlg, oLbx, oBtn[3] , nDlgHeight := 100, nRowHeight   := 20, nBrwHeight := 100
LOCAL cItem := oCol:Value, cRet, nBtnTop    := 100, oCal, dDate := Date(), oRadio, nRadio := 1
LOCAL nWidth    := oCol:nWidth - 20, aRadItems[5], oSay
LOCAL nBtnleft  := (( nWidth - 60 ) / 2 ) + 5

cItem := ALLTRIM(STR(oCol:Value) )

DEFINE DIALOG oDlg SIZE nWidth +23, nDlgHeight PIXEL TRUEPIXEL FONT oListFont ;
STYLE WS_POPUP | WS_THICKFRAME  

IF nSpace = 0
        @ 5, 5 LISTBOX oLbx VAR cItem ITEMS aItems ;
        SIZE nWidth, nBrwHeight  PIXEL OF oDlg
ELSE
        @ 5, 5 LISTBOX oLbx VAR cItem ITEMS aItems BITMAPS aImages ;
        SIZE nWidth, nBrwHeight  PIXEL OF oDlg
ENDIF

oLbx:SetColor( 0, nColor )

oLbx:bLDblClick := { || cRet :=  oLbx:GetSelText(), oDlg:End() }
oLbx:bKeyDown := {|nKey| iif(nKey = 13, ( cRet := oLbx:GetSelText(), oDlg:End() ), ), ; // return
                             iif(nKey = 27, oDlg:End(), ) } // excape

@ nBtnTop, nBtnleft BTNBMP oBtn[1] OF oDlg ;
SIZE 60, 28 PIXEL 2007 ; // B / H
PROMPT "&Cancel" ;
ACTION oDlg:End() ;
FONT oListFont  CENTER BORDER

ACTIVATE DIALOG oDlg ; // adjusted to listbox
ON INIT ( DRAW_BOX(oDlg, oBtn, oLbx, cType, aItems, nSpace, nWidth), ;
         oCol:AnchorToCell( oDlg ), oDlg:SetColor( 0, nColor ) )    // connect to cell

RETURN cRet

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

STATIC FUNCTION DRAW_BOX(oDlg, oBtn, oLbx, aItems, nImgHeight, nWidth)
LOCAL nLbHeight, nItemHeight

nItemHeight  := oLbx:SendMsg( LB_GETITEMHEIGHT, 0, 0 )
nItems := LEN(aItems)
IF nImgHeight = 0
        nLbHeight := nItemHeight * nItems +15 // browser-hight no images
ELSE
        nLbHeight := nImgHeight * nItems +15    // browser-hight with images
ENDIF
oLbx:nHeight := nLbHeight
oLbx:Refresh()
oDlg:Move( 0, 0, nWidth +23, nLbHeight + 50, .t. )  // adjust the dialog to browser

oBtn[1]:nTop := oDlg:nHeight -50
oBtn[1]:Refresh()   // button-position

RETURN nLbHeight
 

Re: Help for a XBrowse

PostPosted: Sun Sep 15, 2019 4:35 pm
by Armando
Ukoenig:

Thanks for you answer but is not exactly what i need, what I need in a TXBrowse to show
a checkbox but for a numeric field, If it is cero value then show a non cheched
checkbox bitmap, if it is greater than cero value then show a checked checkbox
bitmap.

Regards

Re: Help for a XBrowse

PostPosted: Sun Sep 15, 2019 5:01 pm
by ukoenig
Armando,

it is the logic I'm using for the field AGE
< 30 = .T. and >= 30 = .F.
instead of a the checkbox-symbol I use bitmaps YES and NO
These bitmaps can be replaced with checkbox-bitmaps if needed.

regards
Uwe :D

Re: Help for a XBrowse

PostPosted: Sun Sep 15, 2019 5:10 pm
by Armando
ukoening:

Yes you are right, I'll try it.

Regards

Re: Help for a XBrowse

PostPosted: Sun Sep 15, 2019 5:39 pm
by ukoenig
Amando,

the result of the the bitmap-changes

Image

The 2 needed bitmaps with the same size like the checkbox

right mouseclick for download

Image

Image

regards
Uwe :D

Re: Help for a XBrowse

PostPosted: Mon Sep 16, 2019 2:18 pm
by Armando
ukoenig:

Solved, thanks for your clues.

Regards