Page 1 of 3

MENUITEM with BLOCK command executed TWICE. (SOLVED)

PostPosted: Mon May 10, 2021 9:25 pm
by Horizon
Hi,

I use MENU... ENDMENU like below. I use BLOCK command in MENUITEM.

Code: Select all  Expand view
    MENU oFaizMenu POPUP 2007
        MENUITEM "Parameters" ACTION Parametre_FAIZ()
        SEPARATOR
    FOR hh:=1 TO 19
        hhh:="oApp:GParam:xADI_"+ALLTRIM(STR(hh))
        hhh1 := ALLTRIM(&hhh)
        IF !EMPTY(Hhh1)
            MENUITEM hhh1 BLOCK GenBlock_Faiz(hh)
        ENDIF
    Next hh
    ENDMENU

Code: Select all  Expand view
FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN {|| &(cProc)() }


When I select blocked option, it is executed twice. I use fwh 2102 revised. Am I doing something wrong?

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 7:35 am
by nageswaragunupudi
Code: Select all  Expand view
FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN  &( "{|| " + cProc + "() }" )

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 7:42 am
by Horizon
nageswaragunupudi wrote:
Code: Select all  Expand view
FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN  &( "{|| " + cProc + "() }" )


Thank you Mr. Rao,

I have tried but There is still same error.

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 8:52 am
by Silvio.Falconi
ty to insert the action before of the BLOCK


baction := GenBlock_Faiz(hh)
MENUITEM hhh1 BLOCK bAction

FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN {|| &(cProc)() }

on a my menu I make this

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 8:55 am
by Horizon
Silvio.Falconi wrote:ty to insert the action before of the BLOCK


baction := GenBlock_Faiz(hh)
MENUITEM hhh1 BLOCK bAction

FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN {|| &(cProc)() }

on a my menu I make this


Thank you Silvio, Tried and same error.

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:25 am
by Antonio Linares
This example works fine:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU  
   ENDMENU

return oMenu

 

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:30 am
by Antonio Linares
This one also works fine:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK GenBlock()
         ENDMENU  
   ENDMENU

return oMenu

function GenBlock()

return { || MsgInfo( "Hello" ) }  

 

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:33 am
by Antonio Linares
Trying to get an example similar to yours, and this is working fine also:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu, n

   MENU oMenu
      MENUITEM "First"
      MENU
         for n = 1 to 5
            MENUITEM "test" BLOCK GenBlock( n )
         next  
      ENDMENU  
   ENDMENU

return oMenu

function GenBlock( n )

return { || MsgInfo( n ) }  

 

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:33 am
by Silvio.Falconi
yes confirm this run ok

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil



function BuildMenu()

   local oMenu,n,baction

   MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next
         ENDMENU  
   ENDMENU

return oMenu

Function givemefunc(n)
   return { || &( "Hello"+ltrim(str(n)) )() }


  Function Hello4()
     return  Msginfo("run")


 


it run one time probable popmenu run bad

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:38 am
by Horizon
Antonio Linares wrote:This example works fine:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU  
   ENDMENU

return oMenu

 


You are right Antonio,

Please find ribbon.prg from samples directory and change this lines and compile.

Code: Select all  Expand view
  MENU oMenu POPUP 2007
      MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
      MENUITEM "Colors"
      MENUITEM "Font"
      MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
   ENDMENU

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:45 am
by Silvio.Falconi
Horizon wrote:
Antonio Linares wrote:This example works fine:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU  
   ENDMENU

return oMenu

 


You are right Antonio,

Please find ribbon.prg from samples directory and change this lines and compile.

Code: Select all  Expand view
  MENU oMenu POPUP 2007
      MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
      MENUITEM "Colors"
      MENUITEM "Font"
      MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
   ENDMENU




Horizon,
the popup menu run ok

Please try this test with ribbonbar

Code: Select all  Expand view


#include "fivewin.ch"
#include "ribbon.ch"

function Main()

   local oWnd,oRBar,oTBtn0
   local aClrMenu1 := { { 0.5, RGB( 69, 124, 188 ), RGB( 41, 93, 171 ) }, ;
                        { 0.5, RGB( 26, 64, 136 ), RGB( 56, 135, 191 ) } }

   DEFINE WINDOW oWnd MENU BuildMenu()
   DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Configuración", "Ficheros", "Informes", "Ayudas" HEIGHT 133 TOPMARGIN 25


  oTBtn0 = TRBtn():New( 4, 0, 70, 20, "..\bitmaps\rbnmenu.bmp", { || oRBar:BackStage() /* oRBar:KeybMode() */ }, oRBar,;
                         ,,,,,, .T., .T.,,,,,, "POPUP", BuilPopMenu(),,,,,,,,,,,,, aClrMenu1, nRGB( 125, 172, 215 ),;
                         nRGB( 65, 106, 189 ) )




   ACTIVATE WINDOW oWnd

return nil



function BuildMenu()
   local oMenu,n,baction
   MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next
         ENDMENU
   ENDMENU
return oMenu

Function givemefunc(n)
   return { || &( "Hello"+ltrim(str(n)) )() }

  Function Hello4()
    return  Msginfo("run")


Function  BuilPopMenu()
   local oMenu,n,baction
     MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next
         ENDMENU  
   ENDMENU
   return oMen

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:51 am
by Horizon
Silvio.Falconi wrote:
Horizon wrote:
Antonio Linares wrote:This example works fine:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU  
   ENDMENU

return oMenu

 


You are right Antonio,

Please find ribbon.prg from samples directory and change this lines and compile.

Code: Select all  Expand view
  MENU oMenu POPUP 2007
      MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
      MENUITEM "Colors"
      MENUITEM "Font"
      MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
   ENDMENU




Horizon,
the popup menu run ok

Please try this test with ribbonbar

Code: Select all  Expand view


#include "fivewin.ch"
#include "ribbon.ch"

function Main()

   local oWnd,oRBar,oTBtn0
   local aClrMenu1 := { { 0.5, RGB( 69, 124, 188 ), RGB( 41, 93, 171 ) }, ;
                        { 0.5, RGB( 26, 64, 136 ), RGB( 56, 135, 191 ) } }

   DEFINE WINDOW oWnd MENU BuildMenu()
   DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Configuración", "Ficheros", "Informes", "Ayudas" HEIGHT 133 TOPMARGIN 25


  oTBtn0 = TRBtn():New( 4, 0, 70, 20, "..\bitmaps\rbnmenu.bmp", { || oRBar:BackStage() /* oRBar:KeybMode() */ }, oRBar,;
                         ,,,,,, .T., .T.,,,,,, "POPUP", BuilPopMenu(),,,,,,,,,,,,, aClrMenu1, nRGB( 125, 172, 215 ),;
                         nRGB( 65, 106, 189 ) )




   ACTIVATE WINDOW oWnd

return nil



function BuildMenu()
   local oMenu,n,baction
   MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next
         ENDMENU
   ENDMENU
return oMenu

Function givemefunc(n)
   return { || &( "Hello"+ltrim(str(n)) )() }

  Function Hello4()
    return  Msginfo("run")


Function  BuilPopMenu()
   local oMenu,n,baction
     MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next
         ENDMENU  
   ENDMENU
   return oMen


Hi Silvio,

What is your fwh version? After 20.12, there is something strange behavior Menu. I have fwh 21.02.

Please find ribbon.prg from samples directory and change this lines and compile.

Code:
MENU oMenu POPUP 2007
MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
MENUITEM "Colors"
MENUITEM "Font"
MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
ENDMENU

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 9:54 am
by Silvio.Falconi
confirm not run
here run twice

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 3:17 pm
by cnavarro
Please test your compiled example and tell me if it works for you.
https://bitbucket.org/fivetech/fivewin- ... rizon2.exe

Re: MENUITEM with BLOCK command executed TWICE.

PostPosted: Tue May 11, 2021 3:34 pm
by Horizon
cnavarro wrote:Please test your compiled example and tell me if it works for you.
https://bitbucket.org/fivetech/fivewin- ... rizon2.exe


Hi Mr. Navarro,

I could not downloaded the file.