Page 1 of 1

POPMENU WITH ACTION ERROR

PostPosted: Mon Nov 12, 2012 9:23 am
by Silvio.Falconi
When i select an option from menupopup it not call the action why ?


Image




I made this test :

Code: Select all  Expand view


#include "FiveWin.ch"
#include "constant.ch"
#include "Report.ch"
#include "Image.ch"

Function test()
   LOcal  oDlg,oFld

Local aGet[20]

Local cClPassPort:=space(40)


   Local nBottom   := 32
   Local nRight    := 62
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
   Local  oFont  := TFont():New( "Lucida Console", 0, 12,, )

   DEFINE DIALOG oDlg        ;
   TITLE "test PopUp Image"   ;
   SIZE nWidth, nHeight  TRANSPARENT PIXEL


 @ 40,   3 FOLDEREX oFld Items    "&Luogo di spesa abituale",;
                                    "&Internet",;
                                    "&Documenti",;
                                    "&Osservazioni";
                              SIZE 240, 160 PIXEL;
                              OF oDlg// COLOR 0, 14215660


   @ 10, 15 SAY "PassaPorto" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL
   @ 10, 100 SAY "Carta d'Identità" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL
   @ 10, 160 SAY "Tessera Sanitaria" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL



      aGet[14] := TImage():New( 2, 2, 60, 60, , If(!empty(cClPassPort),cClPassPort,".\bitmaps\immagine.bmp"), .t.,;
                                    oFld:aDialogs[ 3 ], , , , , ,;
                                     , .t., , , ,  )
      aGet[14]:bRClicked := {|nRow,nCol| PopImage(nRow,nCol,aGet[14],cClPassPort) }

ACTIVATE DIALOG oDlg

retu nil









Function PopImage(nRow,nCol,oControl,cImage)
local oMenu
local cFile
MENU oMenu POPUP 2007

MENUITEM "&Carica un immagine" ;
ACTION (cImage:=PruebaFoto())
MENUITEM "&Mostra l'immagine" ;
ACTION msginfo()
ENDMENU

ACTIVATE POPUP oMenu OF oControl AT nRow, nCol

RETURN cImage



FUNCTION PruebaFoto()

local cFoto

If MsgNoYes( "Desea buscar una fotografia...","Confirme por favor..." )
cFoto := __BuscaFoto( )
? cFoto
End

Return cFoto


FUNCTION __BuscaFoto( )

local cFile

cFile := cGetFile( "BITMAP (*.bmp)| *.bmp|" + ;
"JPG (*.jpg)| *.jpg|" ;
,"Por Favor Seleccione un Archivo de Imágen" )


if ! Empty( cFile ) .and. File( cFile )
Return cFile
End

return ""

 

Re: POPMENU WITH ACTION ERROR

PostPosted: Tue Nov 13, 2012 10:25 am
by Silvio.Falconi
Any solution ?

Re: POPMENU WITH ACTION ERROR

PostPosted: Tue Nov 13, 2012 10:59 am
by Enrico Maria Giordano
Sorry, but all that I get with your sample is an alert box (using latest FWH).

EMG

Re: POPMENU WITH ACTION ERROR

PostPosted: Tue Nov 13, 2012 11:20 am
by Silvio.Falconi
??
I see a dialog with a folder ( but I not have the last fwh)


Image

Re: POPMENU WITH ACTION ERROR

PostPosted: Tue Nov 13, 2012 11:50 am
by Enrico Maria Giordano
Sorry, it's a problem with latest xHarbour. I'm going to report it. Regarding your problem, try this:

Code: Select all  Expand view
ACTIVATE MENU oMenu AT nRow, nCol OF oControl:oWnd


EMG

Re: POPMENU WITH ACTION ERROR

PostPosted: Tue Nov 13, 2012 2:18 pm
by Silvio.Falconi
thanks!!!
now run ok!!!

Re: POPMENU WITH ACTION ERROR

PostPosted: Wed Nov 14, 2012 11:47 am
by Silvio.Falconi
Dear Emg
the action run ok now but when I call

aGet[14] := TImage():New( 2, 2, 60, 60, , If(!empty(cClPassPort),cClPassPort,".\bitmaps\immagine.bmp"), .t.,;
oFld:aDialogs[ 3 ], , , , , ,;
, .t., , , , )
aGet[14]:bRClicked := {|nRow,nCol| PopImage(nRow,nCol,aGet[14],cClPassPort) }

not send to function the value of cClPassPort changed ( the user select the image before) and the control timage have the lupdate=.t.

Re: POPMENU WITH ACTION ERROR

PostPosted: Wed Nov 14, 2012 1:06 pm
by Enrico Maria Giordano
Try

Code: Select all  Expand view
aGet[14]:bRClicked := {|nRow,nCol| cClPassPort := PopImage(nRow,nCol,aGet[14],cClPassPort) }


or

Code: Select all  Expand view
aGet[14]:bRClicked := {|nRow,nCol| PopImage(nRow,nCol,aGet[14],@cClPassPort) }


EMG

Re: POPMENU WITH ACTION ERROR

PostPosted: Wed Nov 14, 2012 1:53 pm
by Silvio.Falconi
I saw it is strange because it call all bmp files

when the user keep a jpg file it not save it on variable cClPassPort

to show the image I use this simply function

Code: Select all  Expand view

 Function Imagen(oControl,cBmpFile)
          Local nBottom   := 24.2
          Local nRight    := 75
          Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
          Local nHeight := nBottom * DLG_CHARPIX_H
          Local oDlg

          Local oBmp,cFile
     

         DEFINE DIALOG oDlg        ;
                   TITLE i18n("Immagine")    ;
                    SIZE nWidth, nHeight   PIXEL      ;
                   /* GRADIENT { { 1,CLR_WHITE, LIGHTCYAN } } */   ;
                   FONT oApp:oFont


                     @ 1.2, 0 IMAGE oBmp SIZE  295, 166 OF oDlg SCROLL
                     oBmp:Progress( .f. )



            ACTIVATE DIALOG oDlg CENTERED  ;
                         ON INIT (BarDialogImage(oBmp,oDlg),oBmp:LoadImage( ,cBmpFile ))
                                               return NIL
 


the command on init ...oBmp:LoadImage( ,cBmpFile ) not load the image jpg

Re: POPMENU WITH ACTION ERROR

PostPosted: Wed Nov 14, 2012 3:30 pm
by FranciscoA
Silvio, here some modifications on your code.
Code: Select all  Expand view
Function test()
   LOcal  oDlg,oFld
   local aGet[20]
   Local cClPassPort:=space(40)
   Local nBottom   := 32
   Local nRight    := 62
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
   Local  oFont  := TFont():New( "Lucida Console", 0, 12,, )

   DEFINE DIALOG oDlg        ;
   TITLE "test PopUp Image"   ;
   SIZE nWidth, nHeight  TRANSPARENT PIXEL

 @ 40,   3 FOLDEREX oFld Items    "&Luogo di spesa abituale",;
                                    "&Internet",;
                                    "&Documenti",;
                                    "&Osservazioni";
                              SIZE 240, 160 PIXEL;
                              OF oDlg// COLOR 0, 14215660

   @ 10, 15 SAY "PassaPorto" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL
   @ 10, 100 SAY "Carta d'Identità" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL
   @ 10, 160 SAY "Tessera Sanitaria" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL

      aGet[14] := TImage():New( 2, 2, 60, 60, , If(!empty(cClPassPort),cClPassPort,".\bitmaps\immagine.bmp"), .t.,;
                                    oFld:aDialogs[ 3 ], , , , , ,;
                                     , .t., , , ,  )
      aGet[14]:bRClicked := {|nRow,nCol| PopImage(nRow,nCol,aGet[14],@cClPassPort) }

ACTIVATE DIALOG oDlg

retu nil


Function PopImage(nRow,nCol,oControl,cImage)
local oMenu
local cFile
MENU oMenu POPUP 2007

MENUITEM "&Carica un immagine" ;
ACTION (cImage:=PruebaFoto(@cImage,oControl))
MENUITEM "&Mostra l'immagine" ;
ACTION msginfo()
ENDMENU

ACTIVATE POPUP oMenu AT nRow, nCol OF oControl:oWnd

RETURN cImage



FUNCTION PruebaFoto(cImage,oControl)

local cFoto

If MsgNoYes( "Desea buscar una fotografia...","Confirme por favor..." )
cFoto := __BuscaFoto(@cImage,oControl)
? cFoto
End

Return cFoto


FUNCTION __BuscaFoto(cImage,oControl)

local cFile

cFile := cGetFile( "BITMAP (*.bmp)| *.bmp|" + ;
"JPG (*.jpg)| *.jpg|" ;
,"Por Favor Seleccione un Archivo de Imágen" )


if ! Empty( cFile ) .and. File( cFile )
   oControl:LoadBmp( cFile )
   oControl:lStretch := .t.
   oControl:Refresh()

   Return cFile
End

return ""
 

Regards

Re: POPMENU WITH ACTION ERROR

PostPosted: Thu Nov 15, 2012 11:01 am
by Silvio.Falconi
thanks francisco but I need to call Imagen function to show the image big

I explain on Win xp run ok
Image


on Win seven it not run

if it is a bmp file run ok and I can see the bmp file

if it is a jpg file I cannot see the jpg...strange !!!!

Re: POPMENU WITH ACTION ERROR

PostPosted: Thu Nov 15, 2012 3:37 pm
by FranciscoA
Silvio, using your code with some modifications, this works with .bmp or .jpg (compiled with fw1204-xharbour-bwcc582)
Code: Select all  Expand view

Function test()
   LOcal  oDlg,oFld
   local aGet[20]
   Local cClPassPort:=space(40)
   Local nBottom   := 32
   Local nRight    := 62
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
   Local  oFont  := TFont():New( "Lucida Console", 0, 12,, )

   DEFINE DIALOG oDlg        ;
   TITLE "test PopUp Image"   ;
   SIZE nWidth, nHeight  TRANSPARENT PIXEL

 @ 40,   3 FOLDEREX oFld Items    "&Luogo di spesa abituale",;
                                    "&Internet",;
                                    "&Documenti",;
                                    "&Osservazioni";
                              SIZE 240, 160 PIXEL;
                              OF oDlg// COLOR 0, 14215660

   @ 10, 15 SAY "PassaPorto" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL
   @ 10, 100 SAY "Carta d'Identità" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL
   @ 10, 160 SAY "Tessera Sanitaria" OF oFld:aDialogs[ 3 ] SIZE 65, 8 PIXEL

      aGet[14] := TImage():New( 2, 2, 60, 60, , If(!empty(cClPassPort),cClPassPort,".\bitmaps\immagine.bmp"), .t.,;
                                    oFld:aDialogs[ 3 ], , , , , ,;
                                     , .t., , , ,  )
      aGet[14]:bRClicked := {|nRow,nCol| PopImage(nRow,nCol,aGet[14],@cClPassPort) }

ACTIVATE DIALOG oDlg

retu nil


Function PopImage(nRow,nCol,oControl,cImage)
local oMenu
local cFile
MENU oMenu POPUP 2007

MENUITEM "&Carica un immagine" ;
    ACTION (cImage:=PruebaFoto(@cImage,oControl))
MENUITEM "&Mostra l'immagine" ;
    ACTION Imagen(oControl,@cImage)
ENDMENU

ACTIVATE POPUP oMenu AT nRow, nCol OF oControl:oWnd
RETURN cImage


FUNCTION PruebaFoto(cImage,oControl)
local cFoto

If MsgNoYes( "Desea buscar una fotografia...","Confirme por favor..." )
cFoto := __BuscaFoto(@cImage,oControl)
? cFoto
End
Return cFoto


FUNCTION __BuscaFoto(cImage,oControl)
local cFile

cFile := cGetFile( "BITMAP (*.bmp)| *.bmp|" + ;
"JPG (*.jpg)| *.jpg|" ;
,"Por Favor Seleccione un Archivo de Imágen" )

if ! Empty( cFile ) .and. File( cFile )
   oControl:LoadBmp( cFile )
   oControl:lStretch := .t.
   oControl:Refresh()

   Return cFile
End
return ""

Function Imagen(oControl,cBmpFile)
          Local nBottom   := 24.2
          Local nRight    := 75
          Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
          Local nHeight := nBottom * DLG_CHARPIX_H
          Local oDlg
          Local oBmp,cFile

         DEFINE DIALOG oDlg        ;
                TITLE i18n("Immagine")    ;
                SIZE nWidth, nHeight PIXEL  

msginfo(cbmpfile)

         @ 1.2, 0 IMAGE oBmp SIZE  295, 166 OF oDlg SCROLL
         oBmp:Progress( .f. )

            ACTIVATE DIALOG oDlg CENTERED  ;
                     ON INIT ( oBmp:LoadImage( ,cBmpFile ) )
                    // ON INIT ( oBmp:LoadBmp(cBmpFile), oBmp:lStretch := .t. )   // This works, also.
return NIL
 

Image
http://dc607.4shared.com/img/pLbOj7gh/s7/Imagen.jpg
Regards

Re: POPMENU WITH ACTION ERROR

PostPosted: Thu Nov 15, 2012 4:01 pm
by Silvio.Falconi
thanks perhaps I have an error on pc at work ... on my laptop at home run ok