Mostrar BMP en XBrowse

Mostrar BMP en XBrowse

Postby José Camilo » Thu Apr 08, 2021 1:12 am

Buenas noches. necesito mostrar un .bmp en un xBrowse y no doy en la tecla. el valor para definir el .bmp viene en un campo numerico del dbf ya que puede tomar 3 valores.

asi defino los bmp
local aBtMs:= { ReadBitmap( 0, "TildeR.bmp" ), ;
ReadBitmap( 0, "TildeA.bmp" ), ;
ReadBitmap( 0, "TildeV.bmp" ) }

y asi intente mostrarlo pero obviamente no lo logro hacer.

COLUMNS "numero","FechaError","Tema",if(Corregir->Estado=1,aBtms[1], if(Corregir->Estado=2,aBtms[2],aBtms[3]) ;

Como lo puedo Hacer? ya intente con un eval y tampoco pude.

Gracias
José Camilo
 
Posts: 180
Joined: Wed Apr 07, 2021 3:56 pm

Re: Buenas noches. consulta.

Postby nageswaragunupudi » Thu Apr 08, 2021 8:00 am

METHOD - 1
Code: Select all  Expand view
COLUMNS "numero", "FechaErrpr", "Tema", "" ;

...
...

WITH oBrw:aCols[ 4 ]
   :cHeader := "bmp"  // any header
   :AddBitmap( { "TildeR.bmp", "TildeA.bmp", "TildeV.bmp" } )
   :bBmpData := { || Corregir->Estado }
END
 


Method-2:
Code: Select all  Expand view

local aBmp := { "TildeR.bmp", "TildeA.bmp", "TildeV.bmp" }

...
COLUMNS "numero","FechaError","Tema",{|| aBmp[ Corregir->Estado ] } ;

...

oBrw:aCols[ 4 ]:cDataType := "F"
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Buenas noches. consulta.

Postby José Camilo » Thu Apr 08, 2021 3:09 pm

Hola, gracias. me queda claro.
José Camilo
 
Posts: 180
Joined: Wed Apr 07, 2021 3:56 pm

Re: Mostrar BMP en XBrowse

Postby José Camilo » Thu Apr 08, 2021 5:51 pm

Sr. Roa.
las 2 soluciones que gentilmente me envio a mi consulta, al ejecutarlas me dan error.
"Error Base/1004 Message not found NIL:EVAL"

asi es como lo defino al xBrowse


//DEFINE DIALOG oDlg FROM 1, 1 TO 650, 1444 FONT oFont TITLE 'Clientes' PIXEL
DEFINE DIALOG oDlg FROM 1, 30 TO 650, 850 FONT oFont TITLE 'Correcciones' PIXEL

@ 4,5 XBROWSE oBrw ;
COLUMNS "numero", "FechaError", "Tema", "" ;
COLSIZES -10, -10, -10, -10 OF oDlg ;
SIZE 400,285 PIXEL ;
JUSTIFY .T., .f., .f.,.f. ;
ALIAS cAlias AUTOSORT FOOTERS LINES CELL NOBORDER ;
BACKGROUND aGrad VERTICAL

oBrw:nStretchCol := 2

Por que puede dar el mismo error en los 2 casos?
agradecere su ayuda.
Gracias
José Camilo
 
Posts: 180
Joined: Wed Apr 07, 2021 3:56 pm

Re: Mostrar BMP en XBrowse

Postby José Camilo » Thu Apr 08, 2021 6:15 pm

Listo. ya encontre el problema. ahora el primer metodo muestra la palabra NIL, el segundo metodo funciona correcto.

Gracias
José Camilo
 
Posts: 180
Joined: Wed Apr 07, 2021 3:56 pm

Re: Mostrar BMP en XBrowse

Postby nageswaragunupudi » Fri Apr 09, 2021 1:36 am

Please let us know the FWH version you are using.
We will provide working samples
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mostrar BMP en XBrowse

Postby nageswaragunupudi » Fri Apr 09, 2021 12:53 pm

We give here 4 ways of showing bitmaps based on the field Estado.

Image

Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

static aBmp := { "c:\fwh\bitmaps\32x32\browse.bmp","c:\fwh\bitmaps\32x32\calc.bmp","c:\fwh\bitmaps\32x32\copy.bmp" }

function Main()

   local oDlg, oFont, nRow, nCol

   CreateDBF()

   USE XBRBMP NEW VIA "DBFCDX"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 760,540 PIXEL TRUEPIXEL FONT oFont

   nRow  := nCol  := 20
   Normal(  oDlg, nRow, nCol )
   Method1( oDlg, nRow, nCol += 240 )
   Method2( oDlg, nRow, nCol += 240 )
   Method3( oDlg, nRow += 250, nCol := 20 )
   Method4( oDlg, nRow, nCol += 240 )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

function Normal( oDlg, nRow, nCol )

   local oBrw

   @ nRow,nCol SAY "NO BITMAP" SIZE 100,20 PIXEL OF oDlg
   nRow  += 30
   @ nRow,nCol XBROWSE oBrw SIZE 220,200 PIXEL OF oDlg ;
      DATASOURCE "XBRBMP" COLUMNS "UNITS","TENS","ESTADO" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 32
      :nStretchCol   := 2
      :lHScroll := :lVScroll := .f.
      :CreateFromCode()
   END

return nil

function Method1( oDlg, nRow, nCol )

   local oBrw

   @ nRow,nCol SAY "BmpData" SIZE 100,20 PIXEL OF oDlg
   nRow  += 30
   @ nRow,nCol XBROWSE oBrw SIZE 220,200 PIXEL OF oDlg ;
      DATASOURCE "XBRBMP" COLUMNS "UNITS","TENS","" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 32
      :nStretchCol   := 2
      WITH OBJECT oBrw:aCols[ 3 ]
         :cHeader    := "EST"
         :AddBitmap( aBmp )
         :bBmpData   := { || ( oBrw:cAlias )->ESTADO }
      END
      :lHScroll := :lVScroll := .f.
      :CreateFromCode()
   END

return nil

function Method2( oDlg, nRow, nCol )

   local oBrw

   @ nRow,nCol SAY "BmpFile" SIZE 100,20 PIXEL OF oDlg
   nRow  += 30
   @ nRow,nCol XBROWSE oBrw SIZE 220,200 PIXEL OF oDlg ;
      DATASOURCE "XBRBMP" COLUMNS "UNITS","TENS",{ || aBmp[ ( oBrw:cAlias )->ESTADO ] } ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 32
      :nStretchCol   := 2
      WITH OBJECT oBrw:aCols[ 3 ]
         :cHeader    := "EST"
         :cDataType  := "F"
         :lBmpTransparent := .t.
      END
      :lHScroll := :lVScroll := .f.
      :CreateFromCode()
   END

return nil



function Method3( oDlg, nRow, nCol )

   local oBrw
   local aBmpH[ 3 ]

   AEval( aBmp, { |c,i| aBmpH[ i ] := ReadBitmap( 0, c ) } )

   @ nRow,nCol SAY "Bitmap Handle" SIZE 100,20 PIXEL OF oDlg
   nRow  += 30
   @ nRow,nCol XBROWSE oBrw SIZE 220,200 PIXEL OF oDlg ;
      DATASOURCE "XBRBMP" COLUMNS "UNITS","TENS",{ || aBmpH[ ( oBrw:cAlias )->ESTADO ] } ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 32
      :nStretchCol   := 2
      WITH OBJECT oBrw:aCols[ 3 ]
         :cHeader    := "EST"
         :cDataType  := "P"
         :lBmpTransparent := .t.
      END
      :lHScroll := :lVScroll := .f.
      :CreateFromCode()
   END

return nil

function Method4( oDlg, nRow, nCol )

   local oBrw
   local aBuf[ 3 ]

   AEval( aBmp, { |c,i| aBuf[ i ] := MEMOREAD( c ) } )

   @ nRow,nCol SAY "File Buffer" SIZE 100,20 PIXEL OF oDlg
   nRow  += 30
   @ nRow,nCol XBROWSE oBrw SIZE 220,200 PIXEL OF oDlg ;
      DATASOURCE "XBRBMP" COLUMNS "UNITS","TENS",{ || aBuf[ ( oBrw:cAlias )->ESTADO ] } ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 32
      :nStretchCol   := 2
      WITH OBJECT oBrw:aCols[ 3 ]
         :cHeader    := "EST"
         :cDataType  := "P"
         :lBmpTransparent := .t.
      END
      :lHScroll := :lVScroll := .f.
      :CreateFromCode()
   END

return nil


function CreateDbf()

   local aData := { { "one", "ten", 1 }, { "two", "twenty", 2 }, { "three", "thrity", 3 }, { "four", "forty", 2 } }

   DBCREATE( "XBRBMP", {{ "UNITS", "C", 5, 0 },{ "TENS", "C", 5, 0 },{ "ESTADO", "N", 1, 0 }}, ;
      "DBFCDX", .T., "XBMP" )
   FW_ArrayToDBF( aData )

   CLOSE DATA

return nil

 


We can use any one method we feel convenient.
We recommend Method-1.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 87 guests