FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Detached Local
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Detached Local
Posted: Thu Sep 14, 2023 10:32 PM
hi,

i have something like this
Code (fw): Select all Collapse
   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 (fw): Select all Collapse
   MENUITEM "Player"
   MENU
      AddMenuPlayer()
   ENDMENU
but i always get only "last" Element ...
Code (fw): Select all Collapse
#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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Detached Local
Posted: Fri Sep 15, 2023 02:57 AM
METHOD-1
Code (fw): Select all Collapse
#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 (fw): Select all Collapse
#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 (fw): Select all Collapse
#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 (fw): Select all Collapse
#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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Detached Local
Posted: Fri Sep 15, 2023 10:58 AM

hi,

AH, this Way it work, THX

greeting,

Jimmy

Continue the discussion