FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse from RES. and show images from DLL ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
xBrowse from RES. and show images from DLL ?
Posted: Mon Jul 18, 2016 05: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.



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

The function from the RESOURCE-section

Code (fw): Select all Collapse
// 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: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.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse from RES. and show images from DLL ?
Posted: Wed Jul 20, 2016 05:44 AM

Uwe,

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

thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse from RES. and show images from DLL ?
Posted: 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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse from RES. and show images from DLL ?
Posted: Thu Jul 21, 2016 03:39 PM

Mr Uwe

Please wait for my answer

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse from RES. and show images from DLL ?
Posted: Thu Jul 21, 2016 05:59 PM
Example of using mixed resources
Code (fw): Select all Collapse
#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



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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse from RES. and show images from DLL ?
Posted: Thu Jul 21, 2016 06: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



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 :-)
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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse from RES. and show images from DLL ?
Posted: Thu Jul 21, 2016 06: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse from RES. and show images from DLL ?
Posted: Fri Jul 22, 2016 01:06 AM
Dialog from RC file. I used \fwh\samples\testxbr3.rc
Images in the xbrowse are from DLL
Code (fw): Select all Collapse
#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

Regards



G. N. Rao.

Hyderabad, India
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: xBrowse from RES. and show images from DLL ?
Posted: 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, el teclado y la IA!!"
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: xBrowse from RES. and show images from DLL ?
Posted: 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 :-)
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.

Continue the discussion