bitmap changed from user - RESOLVED !!!

bitmap changed from user - RESOLVED !!!

Postby Silvio » Tue Mar 08, 2011 11:29 pm

I insert a bmp into a dialog

but this bmp must be change when the user select an type of product

I wish that the bitmaps I draw on this picture go on the control of the dialog

Image



local aItems := {"Camera" ,;
"Proiettore" ,;
"Scanner" ,;
"Server" ,;
"Registratore" ,;
"Tv" ,;
"Videocamera" }

when I close the window with small browse I save arrays

if lOK
aControl[20]:= AScan( aItems, Trim( HW->type ))

endif

HW->type is string $ one of the aItems

acontrol[0] must be a number
I want it return me a number


on the dialog main ( see the picture)

I made another array with the list of the bitmaps


Local oggettoBmp:= { 'HARD_01' ,;
'HARD_02' ,;
'HARD_03' ,;
'HARD_04' ,;
'HARD_05' ,;
'HARD_06' ,;
'HARD_07' ,;
'HARD_08' ,;
'HARD_09' ,;
'HARD_10' ,;
'HARD_11' ,;
'HARD_12' ,;
'HARD_13' ,;
'HARD_14' ,;
'HARD_15' ,;
'HARD_16' ,;
'HARD_17' ,;
'HARD_18' ,;
'HARD_19' ,;
'HARD_20' ,;
'HARD_21' }


and on the dialog I insert this command

@ 0, 2 BITMAP aGet[20] RESOURCE oggettoBmp[aGet[20] ] NOBORDER PIXEL OF oDlg SIZE 20,20 UPDATE

perhaps my reason is right but the code is wrong

Can You help me pls
Last edited by Silvio on Thu Mar 10, 2011 11:52 am, edited 1 time in total.
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby Silvio » Wed Mar 09, 2011 12:31 am

Now perhaps I found a solution but also it not refresh the bitmaps
On init cBmp is = "1"


Image


and now you can see a small camera at the right


then I open the selection


Image



on the xbrowse smaller I make me return a value string

aControl[20]:cBmpFile:= STR(AScan( aItems, Trim( HW->type ))) // sample "21"

and on the main dialog I make

@ 2, 250 BITMAP aGet[20] RESOURCE oggettoBmp[val(cBmp)] NOBORDER PIXEL OF oFldMat:aDialogs[1] SIZE 20,20 UPDATE

the problem is it not refresh the bitmaps

when I open the window with the xbrowse smaller (HwSeleccion ) to make the selection I make

@ 5, 133 BUTTON oBtnSel PROMPT "..." OF oFldMat:aDialogs[1] PIXEL SIZE 10, 9 ;
ACTION (HwSeleccion( cInventario, aGet, oDlg ),aGet[20]:cbmpfile:refresh())


but it not refresh the bitmap and make error
Code: Select all  Expand view  RUN
Path and name: C:\work\ERRORI5\GUT\GUT.Exe (32 bits)
   Size: 3,510,784 bytes
   Time from start: 0 hours 0 mins 10 secs
   Error occurred at: 09-03-2011, 01:26:08
   Error description: Error BASE/1004  Class: 'CHARACTER' has no exported method: REFRESH
   Args:
     [   1] = C           21

Stack Calls
===========
   Called from:  => REFRESH(0)
   Called from: source\Pripara.prg => (b)RPEDITA(433)
   Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK(176)
   Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT(1447)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3408)
   Called from:  => SENDMESSAGE(0)



Any Idea ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby Bayron » Wed Mar 09, 2011 1:24 am

Hi Silvio,

I am not sure If I understand correctly, but what you want is to change the picture in the dialog, every time the user moves through the browser???

I have it like this in a regular LISTBOX:

Code: Select all  Expand view  RUN
ON CHANGE ( oImagen:LoadBmp( Articulo->Foto ), oImagen:Refresh() )


The image name is taken directly from the record the browser is placed on....

Hope it helps...
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: bitmap changed from user

Postby Silvio » Wed Mar 09, 2011 1:35 am

Bayron wrote:Hi Silvio,

I am not sure If I understand correctly, but what you want is to change the picture in the dialog, every time the user moves through the browser???

I have it like this in a regular LISTBOX:

Code: Select all  Expand view  RUN
ON CHANGE ( oImagen:LoadBmp( Articulo->Foto ), oImagen:Refresh() )


The image name is taken directly from the record the browser is placed on....

Hope it helps...


I explain you
the user insert a new record
open the dialog
on init the cbmp is = "1" it is camera.bmp
and the dialog at init show this bitmaps
then the user select a product from a selection ( xbrowse or listbox)
the cbmp must be changed
sample if the user select a product with type "scanner"
THE BITMAPS MUST SHOW A SCANNER

I hope you undestand me
the user wat show the type of product on the dialog

but I have a list of resource on a array and I must select one of these
Now when the user select a product the seection return back a number sample 21
I must show the bitmaps number 21 from the array
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby Bayron » Wed Mar 09, 2011 3:41 am

Maybe like this???

Code: Select all  Expand view  RUN
aGet[20]:LoadBmp( oggettoBmp[val(cBmp)] )
aGet[20]:Refresh()
 
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: bitmap changed from user

Postby Silvio » Wed Mar 09, 2011 7:45 am

Bayron,


HwSeleccion( cInventario, aGet, oDlg ) ->> return

aControl[20]:cResName:= STR(AScan( aItems, Trim( HW->type )))

sample : "21"

I made now

@ 5, 133 BUTTON oBtnSel PROMPT "..." OF oFldMat:aDialogs[1] PIXEL SIZE 10, 9 ;
ACTION (HwSeleccion( cInventario, aGet, oDlg ),;
cBmp:= aGet[20]:cResName ,;
aGet[20]:Refresh())



@ 2, 250 BITMAP aGet[20] RESOURCE oggettoBmp[val(trim(cBmp))] NOBORDER PIXEL;
OF oFldMat:aDialogs[1] SIZE 20,20 UPDATE


but now not make error and not show the bitmap but only that initial ( because cBmp at init is "1")
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby ukoenig » Wed Mar 09, 2011 11:58 am

Something like that ???

Selecting a Image from browser, shows Thumbnails on Dialog and inside Folders

Image

Best Regards
Uwe :?:
Last edited by ukoenig on Wed Mar 09, 2011 4:48 pm, edited 2 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: bitmap changed from user

Postby Bayron » Wed Mar 09, 2011 1:09 pm

Silvio,
The problem is that you are not returning cbmp with a value of 21 and then loading the bmp from the array after...


Code: Select all  Expand view  RUN
 cBmp := 1

 //....
 DEfine Dialog xxxx
 //....
 Activate Dialog xxxx ON INIT MakeBrowse(cBmp, aGet.... , ....)
 //....

Function MakeBrowse(cBmp, aGet.... , ....)

Define dialog oDlg
  @1,1 Listbox oLst ..... ......   ON DblClick ( cBmp := RECNO(), aGet[20]:LoadBmp( oggettoBmp[val(cBmp)] ),;
          aGet[20]:Refresh() , oDlg:End())
Activate Dialog oDlg
 


This is the way I have it more or less, and It works for me, doing exactly what you pretend to do...
Sorry for the roughness in the code, I hope It helps you...
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: bitmap changed from user

Postby Silvio » Wed Mar 09, 2011 4:47 pm

No not is the same !!
I must create a test I insert here
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby Silvio » Wed Mar 09, 2011 7:48 pm

Bayron , please try it please
test.prg

Code: Select all  Expand view  RUN



#include "FiveWin.ch"
#include "Report.ch"
#include "xBrowse.ch"
#include "constant.ch"
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO
Function Test()
Local  oDlg
Local  nBottom   := 33
Local  nRight    := 75
Local  nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
Local  nHeight := nBottom * DLG_CHARPIX_H

Local  oggettoBmp:=  { 'HARD_01', 'HARD_02'  }


Local cInventario     := space(30)
Local oFldMat,oBtnSel,aGet[20]
Local cBmp:="1"

RddSetDefault( "DBFCDX" )









       DEFINE DIALOG oDlg  ;  //
        TRANSPARENT SIZE nWidth, nHeight  PIXEL  ;
       TITLE "test" ;
       STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 );

  @ 30, 4  FOLDER oFldMat PIXEL   ;
         ITEMS "&Materiale";
         SIZE 288,50


              @ 5, 5 SAY "&Num. Inventario  :"                           OF oFldMat:aDialogs[1] SIZE 50, 8 PIXEL
              @ 5, 70 GET  aGet[2] VAR cInventario    PICTURE "@!"       OF oFldMat:aDialogs[1]  SIZE 60, 10  PIXEL  UPDATE

              @ 5, 133 BUTTON oBtnSel PROMPT "..." OF oFldMat:aDialogs[1]  PIXEL SIZE  10,  9  ;
                                         ACTION (HwSeleccion( cInventario, aGet, oDlg ),;
                                                cBmp:= aGet[20]:cResName ,;
                                               aGet[20]:Refresh())

              oBtnSel:cTooltip := i18n("selezionare il materiale da riparare")

              @ 2, 250 BITMAP aGet[20] RESOURCE oggettoBmp[val(trim(cBmp))] NOBORDER PIXEL;
              OF oFldMat:aDialogs[1] SIZE 20,20    UPDATE


 ACTIVATE DIALOG oDlg center
retur nil




Function HwSeleccion( cProveed,aControl, oParent )
   local oDlg, oBrowse, oCol, oBtnAceptar, oBtnCancel, oBNew, oBMod, oBDel, oBBus
     local lOk    := .f.
    local aItems := {"CALC"                  ,;
                     "FAX"             }

 Crea_dbf()   // FOR THE TEST

 DEFINE DIALOG oDlg OF oParent    ;
  TITLE "Seleccion" ;
  FROM  0, 0 TO 240, 530 PIXEL



 @05, 10 XBROWSE   oBrowse OF oDlg ;
      SIZE 180,100 PIXEL

 oBrowse:lColDividerComplete := .t.
      oBrowse:lRecordSelector     := .t.
      oBrowse:lHScroll            := .t.
      oBrowse:cAlias := "HW"



   oCol := oBrowse:AddCol()
   oCol:bStrData := { || HW->INVENTARIO }
   oCol:cHeader  := "Inv."
   oCol:nWidth   := 100
   oCol:bLDClickData  := {|| ( lOk := .t., oDlg:End() )   }

   oCol := oBrowse:AddCol()
   oCol:bStrData := { || HW->TYPE }
   oCol:cHeader  := "Tipo"
   oCol:nWidth   := 50
   oCol:bLDClickData  := {|| ( lOk := .t., oDlg:End() )   }




   WITH OBJECT  oBrowse
      WITH OBJECT  oBrowse:aCols[2]
                        :AddResource( 'HARD_01')
                        :AddResource( 'HARD_02')
                        :bBmpData := { || AScan( aItems, Trim( HW->type ))   }
                        :bStrData  := { || " "  }
                     END
                   END


 oBrowse:SetRDD()
 oBrowse:CreateFromCode()


  @ 80, 202 BUTTON oBtnAceptar PROMPT "&Select" ;
            SIZE 45, 12 PIXEL OF oDlg ;
             ACTION (lOk := .t., oDlg:End())

      @ 94, 202 BUTTON oBtnCancel PROMPT "&Exit" ;
             SIZE 45, 12 PIXEL OF oDlg ;
             ACTION (lOk := .f., oDlg:End())






ACTIVATE DIALOG oDlg CENTERED


 if lOK
      aControl[2]:cText := alltrim(Hw->Inventario)

      aControl[20]:cResName:=  STR(AScan( aItems, Trim( HW->type )))

   endif


return nil





Function Crea_dbf()

         DbCreate('Hw', {{'Seriale'    , 'C',   30,   0}  ,;
                         {'Type'       , 'C',   20,   0} ,;
                         {'Marca'      , 'C',   30,   0} ,;
                         {'Modello'    , 'C',   30,   0} ,;
                         {'Laboratory' , 'C',   30,   0} ,;
                         {'TypeLab'    , 'N',   1,    0} ,;
                         {'Licenza1'   , 'C',   30,   0} ,;
                         {'Licenza2'   , 'C',   30,   0} ,;
                         {'Tipo1'      , 'C',   15,   0} ,;
                         {'Tipo2'      , 'C',   15,   0} ,;
                         {'Attivato'   , 'N',   1,    0} ,;
                         {'Ripri1'     , 'L',   1,    0} ,;
                         {'Dischi1'    , 'N',   2,    0} ,;
                         {'Ripri2'     , 'L',   1,    0} ,;
                         {'Dischi2'    , 'N',   2,    0} ,;
                         {'Inventario' , 'C',   10,   0} ,;
                         {'Dotazione'  , 'C',   10,   0} ,;
                         {'Dotaltro'   , 'C',   20,   0} ,;
                         {'Dotaltro2'  , 'C',   20,   0} ,;
                         {'Appunti'    , 'M',  10,    0}}, 'DBFCDX')


    close all
      use &('Hw') alias Hw new
      select Hw
      if FILE('HARDWARE.DBF')
         delete file &('HARDWARE.cdx')
         append from &('HARDWARE')
         dbcommitall()
         close all
         delete file &('HARDWARE.dbf')
         delete file &('HARDWARE.fpt')
      endif
      close all
      rename &('Hw.dbf') to &('HARDWARE.dbf')
      rename &('Hw.fpt') to &('HARDWARE.fpt')


      use HARDwARE alias HW new

                 HW->(DbAppend())
                  Replace   HW->INVENTARIO   with "5555"
                  Replace   HW->TYPE   with "CALC"
                 HW->(DbAppend())
                  Replace   HW->INVENTARIO   with "9999"
                  Replace   HW->TYPE   with "FAX"

      return nil

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






 






testrc.rc

Code: Select all  Expand view  RUN

HARD_01 BITMAP "CALC.BMP"
HARD_02 BITMAP "FAX.BMP"
 




I use the bitmaps file you can found on .\bitmaps\32x32 folder of fwh



When you compile it
you 'll see a bitmap on the dialog

press on button near the get

it open a dialog and select a record

you 'll see it not change the bitmap is on dialog
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby Daniel Garcia-Gil » Wed Mar 09, 2011 10:48 pm

Silvio


this line return a number...

Code: Select all  Expand view  RUN
aControl[20]:cResName:=  STR(AScan( aItems, Trim( HW->type )))


why do you use the number??.... is wrong...
you need a resource/file name...

you should use LoadBMP or LoadImage (Bayron told you)
look inside the class to see arguments

like this...

Code: Select all  Expand view  RUN
             @ 5, 133 BUTTON oBtnSel PROMPT "..." OF oFldMat:aDialogs[1]  PIXEL SIZE  10,  9  ;
                                         ACTION (HwSeleccion( cInventario, aGet, oDlg ),;
                                               aGet[20]:Refresh())

...

Code: Select all  Expand view  RUN
             @ 2, 250 BITMAP aGet[20] NOBORDER PIXEL;
              OF oFldMat:aDialogs[1] SIZE 20,20    UPDATE


Code: Select all  Expand view  RUN
aControl[20]:LoadImage( AllTrim( aItems[ AScan( aItems, Trim( HW->type )) ] ) )


this return a resource name....
Code: Select all  Expand view  RUN
AllTrim( aItems[ AScan( aItems, Trim( HW->type )) ] )



you need take control about AScan( aItems, Trim( HW->type )) ] because can return 0 and the program will crash...
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: bitmap changed from user

Postby Silvio » Wed Mar 09, 2011 11:06 pm

Daniel,

this is Know already...

the problem is another...

On hwselecion() function ( this function is on another file prg )

I have this array with all element

local aItems := {"Camera" ,;
"Camera2" ,;
"Casse acustiche" ,;
"Computer" ,;
"Portatile" ,;
"Lim" ,;
"Megafono" ,;
"Microfono" ,;
"Telefono" ,;
"Monitor" ,;
"Mouse" ,;
"NetTop" ,;
"Pda" ,;
"Plasma-tv" ,;
"Stampante" ,;
"Proiettore" ,;
"Scanner" ,;
"Server" ,;
"Registratore" ,;
"Tv" ,;
"Videocamera" }





and if I insert as return value this line
aControl[20]:LoadImage( AllTrim( aItems[ AScan( aItems, Trim( HW->type )) ] ) )

go to load an image and not a number ( but I need a number not a cbmfile name)

if the number is 21

for sample it make aControl[20]:LoadImage( "Videocamera")


it is right !


But on the dialog I have another ..array


with the names of resources ( These are corresponding to the first array but go to load resources)


Local oggettoBmp:= { 'HARD_01' ,;
'HARD_02' ,;
'HARD_03' ,;
'HARD_04' ,;
'HARD_05' ,;
'HARD_06' ,;
'HARD_07' ,;
'HARD_08' ,;
'HARD_09' ,;
'HARD_10' ,;
'HARD_11' ,;
'HARD_12' ,;
'HARD_13' ,;
'HARD_14' ,;
'HARD_15' ,;
'HARD_16' ,;
'HARD_17' ,;
'HARD_18' ,;
'HARD_19' ,;
'HARD_20' ,;
'HARD_21' }



if I load the "videocamera" image ---> ( aControl[20]:LoadImage( "Videocamera") )

not load anything !

because it not found the resource corresponding and then it not show the new bitmaps on the dialog

I hope you understand
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: bitmap changed from user

Postby Daniel Garcia-Gil » Thu Mar 10, 2011 12:10 am

Silvio

it's your code working, like i said you

i dont know what do you do...but is VERY EASY

download here: http://www.sitasoft.net/fivewin/samples/silvio.zip

Code: Select all  Expand view  RUN

#include "FiveWin.ch"
#include "Report.ch"
#include "xBrowse.ch"
#include "constant.ch"
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO
Function Test()
Local  oDlg
Local  nBottom   := 33
Local  nRight    := 75
Local  nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
Local  nHeight := nBottom * DLG_CHARPIX_H

Local  oggettoBmp:=  { 'calc', 'fax' }


Local cInventario     := space(30)
Local oFldMat,oBtnSel,aGet[20]
Local cBmp:="1"

RddSetDefault( "DBFCDX" )









       DEFINE DIALOG oDlg  ;  //
        TRANSPARENT SIZE nWidth, nHeight  PIXEL  ;
       TITLE "test" ;
       STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 );

  @ 30, 4  FOLDER oFldMat PIXEL   ;
         ITEMS "&Materiale";
         SIZE 288,50


              @ 5, 5 SAY "&Num. Inventario  :"                           OF oFldMat:aDialogs[1] SIZE 50, 8 PIXEL
              @ 5, 70 GET  aGet[2] VAR cInventario    PICTURE "@!"       OF oFldMat:aDialogs[1]  SIZE 60, 10  PIXEL  UPDATE

              @ 5, 133 BUTTON oBtnSel PROMPT "..." OF oFldMat:aDialogs[1]  PIXEL SIZE  10,  9  ;
                                         ACTION (HwSeleccion( cInventario, aGet, oDlg ),;
                                               aGet[20]:Refresh())

              oBtnSel:cTooltip := i18n("selezionare il materiale da riparare")

              @ 2, 250 BITMAP aGet[20] NOBORDER PIXEL;
              OF oFldMat:aDialogs[1] SIZE 20,20    UPDATE


 ACTIVATE DIALOG oDlg center
retur nil




Function HwSeleccion( cProveed,aControl, oParent )
   local oDlg, oBrowse, oCol, oBtnAceptar, oBtnCancel, oBNew, oBMod, oBDel, oBBus
     local lOk    := .f.
    local aItems := {"CALC",;
                     "FAX" }

 Crea_dbf()   // FOR THE TEST

 DEFINE DIALOG oDlg OF oParent    ;
  TITLE "Seleccion" ;
  FROM  0, 0 TO 240, 530 PIXEL



 @05, 10 XBROWSE   oBrowse OF oDlg ;
      SIZE 180,100 PIXEL

 oBrowse:lColDividerComplete := .t.
      oBrowse:lRecordSelector     := .t.
      oBrowse:lHScroll            := .t.
      oBrowse:cAlias := "HW"



   oCol := oBrowse:AddCol()
   oCol:bStrData := { || HW->INVENTARIO }
   oCol:cHeader  := "Inv."
   oCol:nWidth   := 100
   oCol:bLDClickData  := {|| ( lOk := .t., oDlg:End() )   }

   oCol := oBrowse:AddCol()
   oCol:bStrData := { || HW->TYPE }
   oCol:cHeader  := "Tipo"
   oCol:nWidth   := 50
   oCol:bLDClickData  := {|| ( lOk := .t., oDlg:End() )   }




   WITH OBJECT  oBrowse
      WITH OBJECT  oBrowse:aCols[2]
                        :AddResource( 'calc')
                        :AddResource( 'fax')
                        :bBmpData := { || AScan( aItems, Trim( HW->type ))   }
                        :bStrData  := { || " "  }
                     END
                   END


 oBrowse:SetRDD()
 oBrowse:CreateFromCode()


  @ 80, 202 BUTTON oBtnAceptar PROMPT "&Select" ;
            SIZE 45, 12 PIXEL OF oDlg ;
             ACTION (lOk := .t., oDlg:End())

      @ 94, 202 BUTTON oBtnCancel PROMPT "&Exit" ;
             SIZE 45, 12 PIXEL OF oDlg ;
             ACTION (lOk := .f., oDlg:End())






ACTIVATE DIALOG oDlg CENTERED


 if lOK
      aControl[2]:cText := alltrim(Hw->Inventario)

      aControl[20]:LoadImage( AllTrim( aItems[ AScan( aItems, Trim( HW->type )) ] ) )

   endif


return nil





Function Crea_dbf()

         DbCreate('Hw', {{'Seriale'    , 'C',   30,   0}  ,;
                         {'Type'       , 'C',   20,   0} ,;
                         {'Marca'      , 'C',   30,   0} ,;
                         {'Modello'    , 'C',   30,   0} ,;
                         {'Laboratory' , 'C',   30,   0} ,;
                         {'TypeLab'    , 'N',   1,    0} ,;
                         {'Licenza1'   , 'C',   30,   0} ,;
                         {'Licenza2'   , 'C',   30,   0} ,;
                         {'Tipo1'      , 'C',   15,   0} ,;
                         {'Tipo2'      , 'C',   15,   0} ,;
                         {'Attivato'   , 'N',   1,    0} ,;
                         {'Ripri1'     , 'L',   1,    0} ,;
                         {'Dischi1'    , 'N',   2,    0} ,;
                         {'Ripri2'     , 'L',   1,    0} ,;
                         {'Dischi2'    , 'N',   2,    0} ,;
                         {'Inventario' , 'C',   10,   0} ,;
                         {'Dotazione'  , 'C',   10,   0} ,;
                         {'Dotaltro'   , 'C',   20,   0} ,;
                         {'Dotaltro2'  , 'C',   20,   0} ,;
                         {'Appunti'    , 'M',  10,    0}}, 'DBFCDX')


    close all
      use &('Hw') alias Hw new
      select Hw
      if FILE('HARDWARE.DBF')
         delete file &('HARDWARE.cdx')
         append from &('HARDWARE')
         dbcommitall()
         close all
         delete file &('HARDWARE.dbf')
         delete file &('HARDWARE.fpt')
      endif
      close all
      rename &('Hw.dbf') to &('HARDWARE.dbf')
      rename &('Hw.fpt') to &('HARDWARE.fpt')


      use HARDwARE alias HW new
      zap
                 HW->(DbAppend())
                  Replace   HW->INVENTARIO   with "5555"
                  Replace   HW->TYPE   with "CALC"
                 HW->(DbAppend())
                  Replace   HW->INVENTARIO   with "9999"
                  Replace   HW->TYPE   with "FAX"

      return nil

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

 


RC FILE
Code: Select all  Expand view  RUN

calc BITMAP "calc.bmp"
fax  BITMAP "fax.bmp"
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: bitmap changed from user

Postby James Bott » Thu Mar 10, 2011 12:36 am

Falconi,

I am not at all sure that I understand what you are trying to do, but I will attempt a solution based on my assumptions.

I have this array with all element

local aItems := {"Camera" ,;
"Camera2" ,;
"Casse acustiche" ,;
"Computer" ,;
"Portatile" ,;
"Lim" ,;
"Megafono" ,;
"Microfono" ,;
"Telefono" ,;
"Monitor" ,;
"Mouse" ,;
"NetTop" ,;
"Pda" ,;
"Plasma-tv" ,;
"Stampante" ,;
"Proiettore" ,;
"Scanner" ,;
"Server" ,;
"Registratore" ,;
"Tv" ,;
"Videocamera" }


and if I insert as return value this line
aControl[20]:LoadImage( AllTrim( aItems[ AScan( aItems, Trim( HW->type )) ] ) )

go to load an image and not a number ( but I need a number not a cbmfile name)

if the number is 21

for sample it make aControl[20]:LoadImage( "Videocamera")

it is right !

But on the dialog I have another ..array

with the names of resources ( These are corresponding to the first array but go to load resources)

Local oggettoBmp:= { 'HARD_01' ,;
'HARD_02' ,;
'HARD_03' ,;
'HARD_04' ,;
'HARD_05' ,;
'HARD_06' ,;
'HARD_07' ,;
'HARD_08' ,;
'HARD_09' ,;
'HARD_10' ,;
'HARD_11' ,;
'HARD_12' ,;
'HARD_13' ,;
'HARD_14' ,;
'HARD_15' ,;
'HARD_16' ,;
'HARD_17' ,;
'HARD_18' ,;
'HARD_19' ,;
'HARD_20' ,;
'HARD_21' }


If I understand correctly, aItems contains a name but the name is NOT the name of the bitmap in the resource file. If that is correct, then the simple solution is to rename the resources with the same name as that in aItems. This is what I would do.

The next simplest solution is to use the location of the name in aItems to construct the name of the resource.

>if the number is 21

I am assuming this number is what is in HW->type?

You don't need the oggettobmp array, you can simply create the name of the resource from the number, 21, like this:

cBMPName := "HARD_"+ltrim(str(HW->type))

Then you can do:

aControl[20]:LoadImage( cBMPName )

Or, even simpler but harder to read:

aControl[20]:LoadImage( "HARD_"+ltrim(str(HW->type)) )

Alternately, using the array, you can do:

aControl[20]:LoadImage( oggettobmp[HW->type] )

OK, I hope that I understood what you are trying to do, and that helps with a solution.

-----------------
I do note that you sometimes use a leading "o" for variable names that are not objects. This does not follow Hungarian convention and does make it more difficult for others to read and understand your code. For instance, you use oggettobmp to refer to an array. I suggest using a leading "a" instead of "o." You did use an "a" for aItems.

Best Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: bitmap changed from user

Postby Silvio » Thu Mar 10, 2011 9:03 am

I understand YOU understood me but for Daniel solution or James solution I must rewrite all my sources

because

on file pHardware.prg
I have the function hwselection() with array aItems with name of the products
and this function run also for another dialogs good

on file Pripara.prg
I have another dialog with another array ( with the name of resources corresponding to pictures of products)
I must take from hwselecction() function

If I take the daniel solution I must change on Pripara.prg many functions because the mine array is used also on another xbrowses

If I take the James solution I must rewrite Pripara.prg arrays

I ' working from one year to this application, I'm translating over 5000 lines from an Dos clipper ( andfw) oldest application I made on 1992 , I very tired...

I must try to make small modifies on sources ....
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests