aEval( oMenu:aItems ) ?? ( Now It's Ok! )

aEval( oMenu:aItems ) ?? ( Now It's Ok! )

Postby JC » Mon Nov 03, 2008 1:53 pm

Antonio and friends,

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

Code: Select all  Expand view
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
Last edited by JC on Tue Nov 11, 2008 1:34 pm, edited 1 time in total.
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Daniel Garcia-Gil » Mon Nov 03, 2008 2:12 pm

put outside MENU/ENDMENU
Code: Select all  Expand view
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 ) } } )
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby JC » Fri Nov 07, 2008 7: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Fri Nov 07, 2008 8:22 pm

Julio,

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

Has cAlias a right value ?
regards, saludos

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

Postby JC » 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!
Code: Select all  Expand view
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Mon Nov 10, 2008 5: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Mon Nov 10, 2008 6:05 pm

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

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

Postby JC » Mon Nov 10, 2008 6: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Mon Nov 10, 2008 6: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.
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Mon Nov 10, 2008 6:39 pm

I have this situation:
Image

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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Mon Nov 10, 2008 7:39 pm

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

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

Postby JC » Mon Nov 10, 2008 8: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Mon Nov 10, 2008 9:15 pm

Júlio,

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

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

With that change, this example works fine:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » 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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests