Detached Local

Detached Local

Postby Jimmy » Thu Sep 14, 2023 10:32 pm

hi,

i have something like this
Code: Select all  Expand view  RUN
  MENUITEM "Player"
   MENU
   MENUITEM "Player &1" ACTION PlayNoNext(1)
   MENUITEM "Player &2" ACTION PlayNoNext(2)
   MENUITEM "Player &3" ACTION PlayNoNext(3)
   MENUITEM "Player &4" ACTION PlayNoNext(4)
   MENUITEM "Player &5" ACTION PlayNoNext(5)
   MENUITEM "Player &6" ACTION PlayNoNext(6)
   MENUITEM "Player &7" ACTION PlayNoNext(7)
   MENUITEM "Player &8" ACTION PlayNoNext(8)
   MENUITEM "Player &9" ACTION PlayNoNext(9)
   ENDMENU

now i want to make this while it can be Different Layout
Code: Select all  Expand view  RUN
  MENUITEM "Player"
   MENU
      AddMenuPlayer()
   ENDMENU

but i always get only "last" Element ...
Code: Select all  Expand view  RUN
#include "fivewin.ch"
#define Use_Detach_Local
STATIC nRow     := 3
STATIC nCol     := 3

function Main()
local oWnd, oMenu

   DEFINE WINDOW oWnd MENU MyMenu2()
   ACTIVATE WINDOW oWnd CENTERED

return nil

function MyMenu2()
LOCAL oPopup

   MENU oPopup
   MENUITEM "Player"
      MENU
#ifdef Use_Detach_Local
      AddMenuPlayer()
#else
      MENUITEM "Player &1" ACTION PlayNoNext(1)
      MENUITEM "Player &2" ACTION PlayNoNext(2)
      MENUITEM "Player &3" ACTION PlayNoNext(3)
      MENUITEM "Player &4" ACTION PlayNoNext(4)
      MENUITEM "Player &5" ACTION PlayNoNext(5)
      MENUITEM "Player &6" ACTION PlayNoNext(6)
      MENUITEM "Player &7" ACTION PlayNoNext(7)
      MENUITEM "Player &8" ACTION PlayNoNext(8)
      MENUITEM "Player &9" ACTION PlayNoNext(9)
#endif
      ENDMENU
   ENDMENU

RETURN oPopup

PROCEDURE PlayNoNext(nNo)
   Msginfo(STR(nNo))
RETURN

PROCEDURE AddMenuPlayer()
LOCAL xx,yy,bBlock, nCount := 0

   FOR yy := 1 TO nRow
      xx := 1
      FOR xx := 1 TO nCol
       nCount++
       MENUITEM "Player "+LTRIM(STR(nCount)) ACTION  DoDeachLocal(nCount)
    NEXT
   NEXT
RETURN

FUNCTION DoDeachLocal(nNo)
LOCAL cRet := "{|| PlayNoNext(" + STR(nNo) +") }"
LOCAL bBlock := &(cRet)

   EVAL(bBlock)

RETURN nil
 

who can help me please
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Detached Local

Postby nageswaragunupudi » Fri Sep 15, 2023 2:57 am

METHOD-1
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oWnd, oMenu, n

   MENU oMenu
      MENUITEM "Player"
      MENU
         for n := 1 to 9
            PlayMenuItem( n )
         next
      ENDMENU
   ENDMENU

   DEFINE WINDOW oWnd MENU oMenu
   ACTIVATE WINDOW oWnd CENTERED

return nil

static function PlayMenuItem( n )

   MENUITEM "Player &" + Str( n, 1, 0 ) ACTION PlayNoNext( n )

return nil

static function PlayNoNext( n );MsgInfo( n );return nil
 


METHOD-2
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oWnd, oMenu, n

   MENU oMenu
      MENUITEM "Player"
      MENU
         for n := 1 to 9
            MENUITEM "Player &" + Str( n, 1, 0 ) ;
               BLOCK PlayItemAction( n )
         next
      ENDMENU
   ENDMENU

   DEFINE WINDOW oWnd MENU oMenu
   ACTIVATE WINDOW oWnd CENTERED

return nil

static function PlayItemAction( n )
return { || PlayNoNext( n ) }

static function PlayNoNext( n );MsgInfo( n );return nil
 


METHOD-3
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oWnd, oMenu, n

   MENU oMenu
      MENUITEM "Player"
      MENU
         for n := 1 to 9
            MENUITEM "Player &" + Str( n, 1, 0 ) ;
               ACTION PlayNoNext( Val( Right( oMenuItem:cPrompt, 1 ) ) )
         next
      ENDMENU
   ENDMENU

   DEFINE WINDOW oWnd MENU oMenu
   ACTIVATE WINDOW oWnd CENTERED

return nil

static function PlayNoNext( n );MsgInfo( n );return nil
 


METHOD-4
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oWnd, oMenu, oItem, n

   MENU oMenu
      MENUITEM "Player"
      MENU
         for n := 1 to 9
            MENUITEM oItem PROMPT "Player &" + Str( n, 1, 0 ) ;
               ACTION PlayNoNext( oMenuItem:Cargo )
            oItem:Cargo := n
         next
      ENDMENU
   ENDMENU

   DEFINE WINDOW oWnd MENU oMenu
   ACTIVATE WINDOW oWnd CENTERED

return nil

static function PlayNoNext( n );MsgInfo( n );return nil
 
Regards

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

Re: Detached Local

Postby Jimmy » Fri Sep 15, 2023 10:58 am

hi,

AH, this Way it work, THX
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 27 guests