MENUITEM with BLOCK command executed TWICE. (SOLVED)

MENUITEM with BLOCK command executed TWICE. (SOLVED)

Postby Horizon » Mon May 10, 2021 9:25 pm

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?
Last edited by Horizon on Tue Jun 01, 2021 1:30 pm, edited 1 time in total.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby nageswaragunupudi » Tue May 11, 2021 7:35 am

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

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

Re: MENUITEM with BLOCK command executed TWICE.

Postby Horizon » Tue May 11, 2021 7:42 am

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.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Silvio.Falconi » Tue May 11, 2021 8:52 am

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Horizon » Tue May 11, 2021 8:55 am

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.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Antonio Linares » Tue May 11, 2021 9:25 am

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

 
regards, saludos

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

Re: MENUITEM with BLOCK command executed TWICE.

Postby Antonio Linares » Tue May 11, 2021 9:30 am

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" ) }  

 
regards, saludos

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

Re: MENUITEM with BLOCK command executed TWICE.

Postby Antonio Linares » Tue May 11, 2021 9:33 am

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 ) }  

 
regards, saludos

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

Re: MENUITEM with BLOCK command executed TWICE.

Postby Silvio.Falconi » Tue May 11, 2021 9:33 am

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Horizon » Tue May 11, 2021 9:38 am

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
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Silvio.Falconi » Tue May 11, 2021 9:45 am

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Horizon » Tue May 11, 2021 9:51 am

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
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby Silvio.Falconi » Tue May 11, 2021 9:54 am

confirm not run
here run twice
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: MENUITEM with BLOCK command executed TWICE.

Postby cnavarro » Tue May 11, 2021 3:17 pm

Please test your compiled example and tell me if it works for you.
https://bitbucket.org/fivetech/fivewin- ... rizon2.exe
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: MENUITEM with BLOCK command executed TWICE.

Postby Horizon » Tue May 11, 2021 3:34 pm

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.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests