xBrowse from RES. and show images from DLL ?

xBrowse from RES. and show images from DLL ?

Postby ukoenig » Mon Jul 18, 2016 5:14 pm

Hello,

Working on the RESOURCE-section of a new sample,
I have a problem to create a xBrowse from resource and displaying the images from a DLL
From CODE there is no problem at all and I could finish this part.
My problem :
The image-array is loaded from the DLL but xbrowse cannot show the images.
I think something must be changed ( the logic ) ?
xBrowse will get only the image-names from the DLL but cannot display / load the resources.

Image

for testing with a DLL You can download :
http://www.pflegeplus.com/DOWNLOADS/Testdll1.zip

The function from the RESOURCE-section

Code: Select all  Expand view

// hSave := GetResources() defined on start-function

// folderpage with xBrowse from RESOURCE
//------------------------------------------------
FUNCTION F_PAGE8( oFld2 )
LOCAL oBrw
LOCAL nI
LOCAL hBitMap1, hBitMap2, hBitMap3, hBitMap4
LOCAL aArray:={}

// From RC-file

REDEFINE XBROWSE oBrw ID 110 OF oFld2:aDialogs[3] columns {1,2,3};
Array aArray sizes {140, 220, 100} LINES CELL autocols fastedit

oBrw:nMarqueeStyle        := 1
oBrw:nRowHeight             := 85
oBrw:lFooter                    := .t.
       
oBrw:aCols[ 1 ]:nEditType       := TYPE_IMAGE
oBrw:aCols[ 1 ]:lBmpStretch := .f.
oBrw:aCols[ 1 ]:lBmpTransparent := .t.
oBrw:aCols[ 1 ]:bStrImage       := {|oCol, oBrw| oBrw:aRow[ 2 ] }
oBrw:aCols[ 1 ]:nDataBmpAlign  := AL_CENTER
oBrw:aCols[ 1 ]:bPopUp      := { | o | ColMenu( o ) }
//oBrw:aCols[ 1 ]:bAlphaLevel     := { | o | o:oBrw:aRow[ 3 ] }

oBrw:aCols[ 2 ]:nEditType       := EDIT_BUTTON
oBrw:aCols[ 2 ]:bEditBlock      := {|nRow, nCol, oCol| oCol:Value := cGetFile( "*.*", "Select a file" )  }
oBrw:aCols[ 2 ]:AddBmpFile( "BOOKS" )
oBrw:aCols[ 2 ]:nHeadBmpNo      := 1

oBrw:aCols[ 3 ]:nEditType       := 1
oBrw:aCols[ 3 ]:bOnPostEdit     := {|oCol, xVal, nKey| oCol:Value( xVal ) }
oBrw:aCols[ 3 ]:AddBmpFile( "BOOKS" )
oBrw:aCols[ 3 ]:nFootBmpNo      := 1

// switch to DLL and load images
 
SET RESOURCES TO c_path + "SYSTEM.dll"

aadd( aArray, { "", "FISH1", 50 } )
aadd( aArray, { "", "FISH2", 100 } )
aadd( aArray, { "", "FISH3", 150 } )  
aadd( aArray, { "", "FISH4", 200 } )
aadd( aArray, { "", "FISH5", 255 } )

oBrw:SetArray( aArray )
oBrw:Refresh()

SetResources( hSave ) // back to RC
 
RETURN NIL
 


regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse from RES. and show images from DLL ?

Postby Antonio Linares » Wed Jul 20, 2016 5:44 am

Uwe,

Is this working fine with the proposed changes to function fnAddBitmap() ?

thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: xBrowse from RES. and show images from DLL ?

Postby ukoenig » Wed Jul 20, 2016 11:45 am

Antonio,

the xBrowse-problem still exists
it is the resource-section I'm still working on.
The tab-painting is working fine with the changes.

http://www.pflegeplus.com/DOWNLOADS/Dlltest1.zip

regards
Uwe :(
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse from RES. and show images from DLL ?

Postby nageswaragunupudi » Thu Jul 21, 2016 3:39 pm

Mr Uwe

Please wait for my answer
Regards

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

Re: xBrowse from RES. and show images from DLL ?

Postby nageswaragunupudi » Thu Jul 21, 2016 5:59 pm

Example of using mixed resources
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oBar, oBrw, hResDLL
   local aData, n

   SET RESOURCES TO "TEST.DLL"
   hResDLL := GetResources()

   aData    := { { hResDLL, "COPY"    }, ;
                 {       0, "OPEN"    }, ;
                 { hResDLL, "CASCADE" }, ;
                 {       0, "CLOSE"   }, ;
                 { hResDLL, "VISA"    }  }


   DEFINE WINDOW oWnd
   DEFINE BUTTONBAR oBar OF oWnd SIZE 48,48 2007
   DEFINE BUTTON OF oBar RESOURCE "COPY"
   SetResources( 0 )
   DEFINE BUTTON OF oBar RESOURCE "Open"
   SetResources( hResDLL )
   DEFINE BUTTON OF oBar RESOURCE "VISA"
   SetResources( 0 )
   DEFINE BUTTON OF oBar RESOURCE "CLOSE"


   @ 48,0 XBROWSE oBrw OF oWnd DATASOURCE aData ;
      COLUMNS 2, "" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw:aCols[ 1 ]

      for n := 1 to Len( aData )
         SetResources( aData[ n, 1 ] )
         :AddBitmap( aData[ n, 2 ] )
      next

      :bBmpData      := { || oBrw:KeyNo }
      :nDataStrAlign := AL_RIGHT
   END

   WITH OBJECT oBrw:aCols[ 2 ]
      :bStrImage        := { || oBrw:oCol( 1 ):aBitmaps[ oBrw:KeyNo, 1 ] }
      :lBmpTransparent  := .t.
      :nDataBmpAlign    := AL_CENTER
      :lBmpStretch      := .t.

   END

   WITH OBJECT oBrw
      :nWidths     := 96
      :CreateFromCode()
   END

   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd CENTERED

return nil
 

Image

In the above browse, images in lines 1,3 and 5 are from test.dll and other images are from .rc file linked to the Exe.

There is no problem with xbrowse.
This is the usage
Regards

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

Re: xBrowse from RES. and show images from DLL ?

Postby ukoenig » Thu Jul 21, 2016 6:31 pm

Mr. Rao,

thank You very much for the sample.

My test is a little bit different : xBrowse from RC ( NOT from code )
and the images from a DLL
instead of images the cell shows any values

Image

SET RESOURCES TO c_path + "SYSTEM.dll"
hResDLL := GetResources()
aArray := { { hResDLL, "FISH1" }, ;
{ hResDLL, "FISH2" }, ;
{ hResDLL, "FISH3" }, ;
{ hResDLL, "FISH4" }, ;
{ hResDLL, "FISH5" } }

SetResources( hSave ) // access from rc

REDEFINE XBROWSE oBrw ID 110 OF oFld2:aDialogs[3] columns {1,2,3};
Array aArray sizes {140, 220, 100} LINES CELL autocols fastedit

maybe a different solution is needed ?

regards
Uwe :?:
Last edited by ukoenig on Thu Jul 21, 2016 6:37 pm, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: xBrowse from RES. and show images from DLL ?

Postby nageswaragunupudi » Thu Jul 21, 2016 6:34 pm

It does not matter whether xbrowse is from rc or source.
What matters is toggling the correct hResources when the resource is read.
As long as you do that there should be no problem.
Regards

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

Re: xBrowse from RES. and show images from DLL ?

Postby nageswaragunupudi » Fri Jul 22, 2016 1:06 am

Dialog from RC file. I used \fwh\samples\testxbr3.rc
Images in the xbrowse are from DLL
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBrw, hResDLL, aData

   // Linked with samples\testxbr3.rc

   SET RESOURCES TO "TEST.DLL"
   hResDLL := GetResources()

   aData := { "COPY", "CASCADE", "VISA" } // all in test.dll

   SetResources( 0 )
   DEFINE DIALOG oDlg RESOURCE "TEST"
   REDEFINE XBROWSE oBrw ID 101 DATASOURCE aData ;
      COLUMNS 1, 1 CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 80
      :nWidths       := 80
      WITH OBJECt :aCols[ 1 ]
         :cDataType        := 'P'
         :nDataBmpAlign    := AL_CENTER
         :lBmpTranspaRent  := .T.
      END
   END

   SetResources( hResDLL )
   ACTIVATE DIALOG oDlg CENTERED
   SET RESOURCES TO

return nil
 


SetResources( 0 ) while creating dialog. So the dialog is created from the RC
While activating dialog SetResources to hResDLL, so that all images are read by xbrowse from the DLL

Image
Regards

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

Re: xBrowse from RES. and show images from DLL ?

Postby jose_murugosa » Fri Jul 22, 2016 11:25 am

En mi caso mis recursos estaban creados con ResEdit y tuve el mismo problema con una dll y solo con xbrowse e imagenes.
Pasé 1 mes por lo menos en ello, finalmente cree el archivo de recursos nuevamente con PellesC y funcionaron perfecamente.
Espero les sea de ayuda.

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

In my case resources were created with ResEdit and I had the same problem with a dll and only with xbrowse and images.
I waste 1 month at least on this. Finnaly I made again the resource file but with PellesC, and resources worked perfectly.
I hope this can be useful.
Saludos/Regards,
José Murugosa
"Los errores en programación, siempre están entre la silla y el teclado y la IA!!"
User avatar
jose_murugosa
 
Posts: 1180
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Re: xBrowse from RES. and show images from DLL ?

Postby ukoenig » Sat Jul 23, 2016 12:04 pm

Jose,

the reason for all my testings is, that I have to change a lot of images at runtime
To link them to the exe or deliver all images is not a clean solution.
I think using a DLL is the best, solving the problem.
Another reason is : I only need to deliver a new DLL if a image-change is needed without changing anything else.

I'm nearly through will all my tests.
I created all DLL's with RESEDIT and couldn't find any display-problems.
From CODE there isn't a problem at all.
Just to switch between RC and DLL needs a different handling.

In my case resources were created with ResEdit and I had the same problem with a dll and only with xbrowse and images.
I waste 1 month at least on this. Finnaly I made again the resource file but with PellesC, and resources worked perfectly.
I hope this can be useful.


regards
Uwe :roll:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 95 guests