FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 03, 2008 01:53 PM
Antonio and friends,

Why this source code not works? Exists a workarea open into cAlias!

MENU oMenu POPUP

     MENUITEM "Test One"   ACTION msgIngo( "Test One" )
     SEPARATOR
     MENUITEM "Test Two"   ACTION msgIngo( "Test Two" )
     MENUITEM "Test Three" ACTION msgIngo( "Test Three" )

     aEval( oMenu:aItems, {|oItem| oItem:bWhen := {|| !( ( cAlias )->( lastRec() ) == 0 ) } } )

ENDMENU
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 03, 2008 02:12 PM
put outside MENU/ENDMENU
MENU oMenu POPUP

     MENUITEM "Test One"   ACTION msgIngo( "Test One" )
     SEPARATOR
     MENUITEM "Test Two"   ACTION msgIngo( "Test Two" )
     MENUITEM "Test Three" ACTION msgIngo( "Test Three" )

ENDMENU

aEval( oMenu:aItems, {|oItem| oItem:bWhen := {|| !( ( cAlias )->( lastRec() ) == 0 ) } } )
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Fri Nov 07, 2008 07:35 PM

Daniel,

Your tip don't works! :(

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Fri Nov 07, 2008 08:22 PM
Julio,

Place a MsgBeep() there to check if the code is properly evaluated:
aEval( oMenu:aItems, {|oItem| oItem:bWhen := {|| MsgBeep(), !( ( cAlias )->( lastRec() ) == 0 ) } } )

Has cAlias a right value ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Sat Nov 08, 2008 12:44 PM
Antonio,

cAlias is "ENT" and "ENT" is a workarea open to my sql result... when I try ( cAlias )->( browse() ), the command show me the rows.

And yes, I tried to use a msginfo( "test" ) in the same place, but still not works!
MENU oMenu POPUP

     MENUITEM "Test One"   ACTION msgIngo( "Test One" )
     SEPARATOR
     MENUITEM "Test Two"   ACTION msgIngo( "Test Two" )
     MENUITEM "Test Three" ACTION msgIngo( "Test Three" )

     aEval( oMenu:aItems, {|oItem| msgInfo( "test" ), oItem:bWhen := {|| !( ( cAlias )->( lastRec() ) == 0 ) } } )

ENDMENU



Outch! :-)
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 05:33 PM

Just to up ;)

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 06:05 PM

As Daniel told you, you have to call AEval() after ENDMENU

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 06:11 PM
Antonio Linares wrote:As Daniel told you, you have to call AEval() after ENDMENU


Antonio,

Ok, but I already tried that! Simply does not work! :-)
I have tried with menu "non popup" and work very fine!
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 06:29 PM
Julio,

Here you have a working example. Please keep in mind that the WHEN expression is evaluated when the menu is going to be created.
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd
   
   ACTIVATE WINDOW oWnd ;
      ON RIGHT CLICK ShowPopup( nRow, nCol, oWnd )

return nil

function ShowPopup( nRow, nCol, oWnd )

   local oPopup
   
   static n := 1

   MENU oPopup POPUP 2007
      MENUITEM "One"   WHEN n++ % 2 == 0
      MENUITEM "Two"   WHEN n++ % 2 == 0
      MENUITEM "Three" WHEN n++ % 2 == 0
   ENDMENU   

   ACTIVATE POPUP oPopup WINDOW oWnd AT nRow, nCol

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 06:39 PM
I have this situation:


Taking into account is that when a block of code, a refresh would not be doing the upgrade of code at "!( ( cAlias )->( lastRec() ) == 0 )" ?

When the number of registers is 0 (zero), the button "OperaçÔes" with a menu popup need to be disabled!

Even after they have created? Or not!?
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 07:39 PM

oBtnOperaciones:bWhen := { || ! ( ( cAlias )->( lastRec() ) == 0 ) }

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 08:00 PM

Antonio,

I've done this, thank you!

However, there are two menu items that need to be empowered independent of the situation, I only not have put in the example.

Exists another way to do it automatically??

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Mon Nov 10, 2008 09:15 PM
JĂșlio,

This change is required in Class TMenu Method Activate()
      ...
      oWnd:oPopup = Self
      ::Initiate()   // New !!!

      TrackPopup( ::hMenu, 2, aPoint[ 1 ], aPoint[ 2 ], 0, oWnd:hWnd )
      ...

With that change, this example works fine:
#include "FiveWin.ch"

function Main()

   local oWnd, oBtn

   DEFINE WINDOW oWnd

   @ 3, 3 BTNBMP oBtn OF oWnd SIZE 80, 25
   
   oBtn:oPopup = BuildMenu()
   
   ACTIVATE WINDOW oWnd 

return nil

function BuildMenu()

   local oPopup
   
   static n := 1

   MENU oPopup POPUP 2007
      MENUITEM "One"   WHEN n++ % 2 == 0
      MENUITEM "Two"   WHEN n++ % 2 == 0
      MENUITEM "Three" WHEN n++ % 2 == 0
   ENDMENU   

return oPopup
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
aEval( oMenu:aItems ) ?? ( Now It's Ok! )
Posted: Tue Nov 11, 2008 11:26 AM

Antonio,

Now works fine! ;)
Thank you.

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9

Continue the discussion