xBrowse: How to display image from resource based on flag

xBrowse: How to display image from resource based on flag

Postby hua » Fri Dec 04, 2020 8:02 am

Hi,
Can someone share a code snippet to view image from resource in a column based on a flag in the dbf currently being viewed?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: xBrowse: How to display image from resource based on flag

Postby nageswaragunupudi » Sun Dec 06, 2020 9:52 pm

This sample demonstrates 3 alternative ways of doing it.
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   USE CUSTOMER NEW SHARED ALIAS CUST VIA "DBFCDX"

   Sample1()
   Sample2()
   Sample3()

return nil

function Sample1()

   local oDlg, oBrw

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS "FIRST", "CITY", "MARRIED" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :married:SetCheck( { "TWO", "ONE" } )
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil

function Sample2()

   local oDlg, oBrw

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS "FIRST", "CITY", "" ;
      HEADERS nil, nil, "MARRIED" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      WITH OBJECT :married
         :AddBitmap( { "ONE", "TWO" } )
         :bBmpData := { || If( ( oBrw:cAlias )->MARRIED, 2, 1 ) }
      END
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil

function Sample3()

   local oDlg, oBrw

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS "FIRST", "CITY", "IF(MARRIED,'TWO','ONE')" ;
      HEADERS nil, nil, "MARRIED" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      WITH OBJECT :married
         :cDataType        := "P"
         :lBmpTransparent  := .t.
      END
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


RC file:
Code: Select all  Expand view
ONE 10     "c:\fwh\bitmaps\32x32\user.bmp"
TWO BITMAP "c:\fwh\bitmaps\32x32\users.bmp"
 


In all the 3 cases, the result is :

Image
Regards

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

Re: xBrowse: How to display image from resource based on flag

Postby hua » Mon Dec 07, 2020 2:49 am

Thank you very much for the extensive example Rao! :D
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: xBrowse: How to display image from resource based on flag

Postby jpcavagnaro » Sun Sep 11, 2022 11:59 am

Rao, excelente, podría decirme como hacer esto con archivo bmp en lugar del RC.

Saludos
Jorge
Jorge
Saludos.
jpcavagnaro
 
Posts: 155
Joined: Tue Oct 11, 2016 1:02 pm
Location: Luján, bs. as.

Re: xBrowse: How to display image from resource based on flag

Postby nageswaragunupudi » Sun Sep 11, 2022 2:29 pm

jpcavagnaro wrote:Rao, excelente, podría decirme como hacer esto con archivo bmp en lugar del RC.

Saludos
Jorge

Substitute resource names with bitmap file names with full path.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests