Actualizar xBrowse con un Clic del ratón?

Re: Actualizar xBrowse con un Clic del ratón?

Postby cmsoft » Sat Aug 19, 2023 12:52 pm

Gracias por su tiempo Mr. Rao
Esto solucionó el error en tiempo de ejecucion
return IfNil( cContents, "" )


local cDefault := MEMOREAD( "c:\fwh\bitmaps\sea.bmp" )

AEval( aCols, { |a,i| a[ 4 ] := WebPageContents( a[ 4 ] ), ;
If( Empty( a[ 4 ] ), a[ 4 ] := cDefault, nil ) } )

Esto muestra solamente la primer foto faltante, pero si hay muchas, las otras no las muestra
Pruebe este ejemplo:
Code: Select all  Expand view
#include "Fivewin.ch"
#include "xbrowse.ch"
FUNCTION cmsoft()
LOCAL oDlg1, oBrwTmp,;
      aCols := {;
{'VIRTUOSA CLASICA',  1900.00, 'Carne 120 grs. Cheddar, Lechuga, Tomate y Mayonesa, Mostaza y Kétchup. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00010110.jpg'},;
{'VIRTUOSA CLASICA 2',  1900.00, 'Carne 120 grs. Cheddar, Lechuga, Tomate y Mayonesa, Mostaza y Kétchup. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00010114.jpg'},;
{'VIRTUOSA MIX',  1900.00, 'Carne 120 grs. Cheddar, Huevo Bacon y BBQ. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000020.jpg'},;
{'VIRTUOSA CHEESE ONION', 1900.00, 'Carne 120 grs. Cheddar, Cebolla Caramelizada Bacon y BBQ. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000021.jpg'},;
{'VIRTUOSA MEGA', 1900.00, 'Carne 120grs. Cheddar, lechuga, pepinos, cebolla picada y salsa mil islas. Incluye papas fritas.','https://bcnresto.com/img/000010/00000022.jpg'},;
{'VIRTUOSA NAPO', 1900.00, 'Carne 120 grs. Jamón, Queso, Tomate y Mayonesa. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000023.jpg'},;
{'BRAHMA 1 L.', 300.00 , 'Bien fria','https://bcnresto.com/img/000010/00000054.jpg'},;
{'BRAHMA 2 L.', 400.00 , 'Bien fria','https://bcnresto.com/img/000010/00000055.jpg'},;
{'BRAHMA 3 L.', 500.00 , 'Bien fria','https://bcnresto.com/img/000010/00000056.jpg'},;
{'BRAHMA 4 L.', 600.00 , 'Bien fria','https://bcnresto.com/img/000010/00000057.jpg'},;
{'BRAHMA 5 L.', 700.00 , 'Bien fria','https://bcnresto.com/img/000010/00000058.jpg'},;
{'BRAHMA 6 L.', 800.00 , 'Bien fria','https://bcnresto.com/img/000010/00000059.jpg'};
}
   local cDefault := MEMOREAD( "c:\fwh21\bitmaps\sea.bmp" )

   AEval( aCols, { |a,i| a[ 4 ] := WebPageContents( a[ 4 ] ), ;
                 If( Empty( a[ 4 ] ), a[ 4 ] := cDefault, nil ) } )

DEFINE DIALOG oDlg1 TITLE "Visor de productos" SIZE 700,700 PIXEL TRUEPIXEL RESIZABLE
   @ 20, 20 XBROWSE oBrwTmp SIZE -20,-20 pixel OF oDlg1 ARRAY aCols  ;
      HEADERS "Producto", "Precio", "Descripcion","Foto";
      COLUMNS 1,2,3,4;
      SIZES nil, nil, 150,200;
      CELL LINES NOBORDER
   WITH OBJECT oBrwTmp
      :nStretchCol   := 3
      :nRowHeight    := 150
      :aCols[4]:cDataType := "P"
      :CreateFromCode()
   END
ACTIVATE DIALOG oDlg1 CENTERED
RETURN nil


Tambien, ya que en realidad los datos los obtengo de una consulta sql, en caso de usar DATASOURCE en lugar de ARRAY habia intentado esto
Code: Select all  Expand view

:aCols[4]:bStrData := {|| IF(EMPTY(WebPageContents( oQry:url, .f. )),MemoRead(".\logo.jpg"),WebPageContents(oQry:url,.f.))  }
 

Y obtenia el mismo efecto, solo mostraba en la primer imagen faltante
Por que puede ser?
Agradezco su interes en el tema
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Actualizar xBrowse con un Clic del ratón?

Postby nageswaragunupudi » Sat Aug 19, 2023 1:22 pm

This shows only the first missing photo, but if there are too many, it doesn't show the others.

But here it is working fine.
I got the default image in all cases.

I extended the array like this:
Code: Select all  Expand view
{'VIRTUOSA NAPO', 1900.00, 'Carne 120 grs. Jamón, Queso, Tomate y Mayonesa. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000023.jpg'},;
{'BRAHMA 1 L.', 300.00 , 'Bien fria','https://bcnresto.com/img/000010/00000054.jpg'}, ;
{'BRAHMA 2 L.', 500.00 , 'Bien fria','https://bcnresto.com/img/000010/00000054.jpg'}, ;
{'BRAHMA 3 L.', 600.00 , 'Bien fria','https://bcnresto.com/img/000010/00000054.jpg'}, ;
{'BRAHMA 4 L.', 700.00 , 'Bien fria','https://bcnresto.com/img/000010/00000054.jpg'};
}
 

I see the default image in all the 4 last rows.

Image

Wondering why is not working for you.
May I know your FWH version? Let me check with your version at my end.
Regards

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

Re: Actualizar xBrowse con un Clic del ratón?

Postby cmsoft » Sat Aug 19, 2023 1:37 pm

Compiler version: Harbour 3.2.0dev (r2008190002)
FiveWin version: FWH 22.06
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Actualizar xBrowse con un Clic del ratón?

Postby cmsoft » Sat Aug 19, 2023 1:49 pm

Mr. Rao:
I extended the array like this:

En la extension del array puso siempre la misma url
Cambie por
Code: Select all  Expand view
     aCols := {;
{'VIRTUOSA CLASICA',  1900.00, 'Carne 120 grs. Cheddar, Lechuga, Tomate y Mayonesa, Mostaza y Kétchup. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00010110.jpg'},;
{'VIRTUOSA CLASICA 2',  1900.00, 'Carne 120 grs. Cheddar, Lechuga, Tomate y Mayonesa, Mostaza y Kétchup. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00010114.jpg'},;
{'VIRTUOSA MIX',  1900.00, 'Carne 120 grs. Cheddar, Huevo Bacon y BBQ. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000020.jpg'},;
{'VIRTUOSA CHEESE ONION', 1900.00, 'Carne 120 grs. Cheddar, Cebolla Caramelizada Bacon y BBQ. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000021.jpg'},;
{'VIRTUOSA MEGA', 1900.00, 'Carne 120grs. Cheddar, lechuga, pepinos, cebolla picada y salsa mil islas. Incluye papas fritas.','https://bcnresto.com/img/000010/00000022.jpg'},;
{'VIRTUOSA NAPO', 1900.00, 'Carne 120 grs. Jamón, Queso, Tomate y Mayonesa. Incluye Papas Fritas.','https://bcnresto.com/img/000010/00000023.jpg'},;
{'BRAHMA 1 L.', 300.00 , 'Bien fria','https://bcnresto.com/img/000010/00000054.jpg'},;
{'BRAHMA 2 L.', 400.00 , 'Bien fria','https://bcnresto.com/img/000010/00000055.jpg'},;
{'BRAHMA 3 L.', 500.00 , 'Bien fria','https://bcnresto.com/img/000010/00000056.jpg'},;
{'BRAHMA 4 L.', 600.00 , 'Bien fria','https://bcnresto.com/img/000010/00000057.jpg'},;
{'BRAHMA 5 L.', 700.00 , 'Bien fria','https://bcnresto.com/img/000010/00000058.jpg'},;
{'BRAHMA 6 L.', 800.00 , 'Bien fria','https://bcnresto.com/img/000010/00000059.jpg'};
}

El error fue mio al copiar y pegar las urls
Puede decirme si esto le muestra todas las imagenes por default?
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Actualizar xBrowse con un Clic del ratón?

Postby nageswaragunupudi » Sat Aug 19, 2023 2:45 pm

You are right.

Please use this:
Code: Select all  Expand view
  AEval( aCols, { |a,i| a[ 4 ] := WebPageContents( a[ 4 ], .f. ), ;
                 If( IsBinaryData( a[ 4 ] ), nil, a[ 4 ] := cDefault ) } )
 
Regards

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

Re: Actualizar xBrowse con un Clic del ratón?

Postby cmsoft » Sat Aug 19, 2023 3:03 pm

Excelente Mr. Rao!!
Ahora si funciona perfecto!
Aprovechando la sugerencia, también hice para el caso de que quiera leer directamente desde la Query
Code: Select all  Expand view

:aCols[4]:bStrData := {|| IF(!IsBinaryData(WebPageContents( oQry:url, .f. )),;
                               MemoRead(".\logo.jpg"),WebPageContents(oQry:url,.f.))  }
 

Y tambien funcionó perfecto!
Si bien, funciona, si quiero hacer un oBrw:Report() luego, no pone las imagenes de los url vacios
Si funciona perfecto si lo hago desde array.
Pero seguire investigando para ver como poder hacerlo.
Muchas gracias por el tiempo dedicado!
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Actualizar xBrowse con un Clic del ratón?

Postby nageswaragunupudi » Tue Aug 22, 2023 2:46 am

Please try this code as it is and then modify to Dolphin
You need to change the default image to your default image in this sample.
Code: Select all  Expand view
FUNCTION cmsoft()

   local oDlg, oBrw
   local cDefault
   local oCn, oRs

   local hImages

   oCn   := maria_Connect( "208.91.198.197:3306,fwhdemo,gnraofwh,Bharat@1950", .t. )
   if oCn == nil
      ? "can not connect to server"
      return nil
   endif

   oRs   := oCn:cmsoft_images

   cDefault := MEMOREAD( "c:\fwh\bitmaps\sea.bmp" )
   cDefault := cValToChar( FW_ReadImage( nil, cDefault )[ 1 ] )

   MsgRun( "Reading", "Images", { || hImages := ReadImages( oRs, cDefault ) } )

   DEFINE DIALOG oDlg TITLE "Visor de productos" SIZE 700,730 PIXEL TRUEPIXEL RESIZABLE

   @ 50, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs  ;
      COLUMNS "Producto", "Precio", "Descripcion","Foto";
      HEADERS nil, nil, nil, "Foto" ;
      SIZES nil, nil, 150,200;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 3
      :nRowHeight    := 150
      WITH OBJECT :aCols[4]
         :cDataType := "P"
         :bEditValue := { || hImages[ oRs:foto ] }
      END
      :CreateFromCode()
   END

   @ 10,20 BUTTON "REPORT" SIZE 100,30 PIXEL OF oDlg ACTION oBrw:Report()

   ACTIVATE DIALOG oDlg CENTERED

   oRs:Close()
   oCn:Close()

   PalBmpFree( Val( cDefault ) )
   HEval( hImages, { |k,v| PalBmpFree( Val( v ) ) } )

RETURN nil

static function ReadImages( oRs, cDefault )

   local hImages, c, n, nRecs

   nRecs := oRs:RecCount()
   oRs:GoTop()

   hImages  := {=>}
   for n := 1 to nRecs
      c  := WebPageContents( oRs:foto )
      if IsBinaryData( c )
         hImages[ oRs:foto ] := cValToChar( FW_ReadImage( nil, c )[ 1 ] )
      else
         hImages[ oRs:foto ] := cDefault
      endif
      oRs:Skip()
   next
   oRs:GoTop()

return hImages

Click on "REPORT" button on the top to generate report
Regards

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

Re: Actualizar xBrowse con un Clic del ratón?

Postby cmsoft » Tue Aug 22, 2023 11:33 am

Excelente Mr. Rao!
Funcionó perfecto!
Muchas gracias por su tiempo!
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Previous

Return to FiveWin para Harbour/xHarbour

Who is online

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