Menuitem error with SetPrompt - Solved

Menuitem error with SetPrompt - Solved

Postby Maurizio » Tue Jul 08, 2014 4:33 pm

Hello

I have to change the text of menuitem .

If I try to oMenu:GetMenuItem(xxx ):cCaption := "Hello" ( or oMenu:GetMenuItem(xxx ):SetPrompt("Hello") )

I have this error :
Error description: Error BASE/1066 Parametro errato: condizionale
TMENUITEM:SETPROMPT( 349 )

FW May 2014 and June 2014

Regards Maurizio
Last edited by Maurizio on Thu Jul 10, 2014 7:39 am, edited 1 time in total.
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Menuitem error with SetPrompt

Postby cnavarro » Tue Jul 08, 2014 6:13 pm

La forma más fácil es asignar un objeto a cada Menuitem
The easiest way is to assign an object to each MenuItem


En este ejemplo oFirst
In this example oFirst
Code: Select all  Expand view


        MENUITEM oFirst PROMPT "&First Alt-F2" MESSAGE "First option" ;
            ACTION If( oFirst:lActive, oFirst:Disable(), oFirst:Enable() ) ;
            ACCELERATOR ACC_ALT, VK_F2
 


Asi es muy sencillo cambiar el texto del MenuItem
That's easy to change the text of the MenuItem

Code: Select all  Expand view

oFirst:SetPrompt( "Cambiado" )
 
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: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menuitem error with SetPrompt

Postby Maurizio » Wed Jul 09, 2014 6:52 am

Thank Navarro

but with your workaround I have the same error.

This is from c:\fwh\samples\resmenu.prg
Code: Select all  Expand view
// Using PullDown Menus from resources

#include "FiveWin.ch"
#include "ResMenu.ch"           // Some IDs for this Test

static oWnd

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 75 ;
      TITLE "Using Menus from resources" ;
      MENU  BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu, oItem ,oItem2

   DEFINE MENU oMenu RESOURCE "Main"

   REDEFINE MENUITEM oItem ID ID_ABOUT OF oMenu ;
      ACTION MsgInfo( "About FiveWin" )

   REDEFINE MENUITEM oItem2  ID ID_TEST  OF oMenu ;
      ACTION MsgInfo( "Testing Resources PullDown Menus" )

   REDEFINE MENUITEM ID ID_EXIT OF oMenu ACTION oWnd:End()

   REDEFINE MENUITEM ID ID_DELETE OF oMenu ACTION MsgInfo( "ok: Delete" )
   
   
   oItem2:SetPrompt( "Cambiado" )


return oMenu

//----------------------------------------------------------------------------//
 


Regards Maurizio
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Menuitem error with SetPrompt

Postby Maurizio » Wed Jul 09, 2014 1:20 pm

Antonio ,

I have the same error with ;

REDEFINE MENUITEM oItem PROMPT " Test " ID ID_ABOUT OF oMenu ;
ACTION MsgInfo( "About FiveWin" )


Code: Select all  Expand view
// Using PullDown Menus from resources

#include "FiveWin.ch"
#include "ResMenu.ch"           // Some IDs for this Test

static oWnd

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 75 ;
      TITLE "Using Menus from resources" ;
      MENU  BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu, oItem ,oItem2

   DEFINE MENU oMenu RESOURCE "Main"

   REDEFINE MENUITEM oItem PROMPT  " Test "  ID ID_ABOUT OF oMenu ;
      ACTION MsgInfo( "About FiveWin" )

   REDEFINE MENUITEM oItem2  ID ID_TEST  OF oMenu ;
      ACTION MsgInfo( "Testing Resources PullDown Menus" )

   REDEFINE MENUITEM ID ID_EXIT OF oMenu ACTION oWnd:End()

   REDEFINE MENUITEM ID ID_DELETE OF oMenu ACTION MsgInfo( "ok: Delete" )
   
   
 

return oMenu

//----------------------------------------------------------------------------//
 


Regards Maurizio
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Menuitem error with SetPrompt

Postby Antonio Linares » Wed Jul 09, 2014 1:23 pm

Maurizio,

Several changes are required in order to fix this FWH bug. First menu.ch has to be changed like this:

In menu.ch:

Code: Select all  Expand view
#xcommand REDEFINE MENUITEM [ <oMenuItem> ] ;
             [ PROMPT <cPrompt> ] ;
             [ ID <nId> <of: OF, MENU> <oMenu> ] ;
             ...
 


In menu.prg:

Code: Select all  Expand view
METHOD ReDefine( cResName, lPopup ) CLASS TMenu

   local hMenu := LoadMenu( GetResources(), cResName )
   local n

   DEFAULT lPopup := .F.

   ::hMenu    = hMenu
   ::aMenuItems   = {}
   ::lSysMenu = .f.
   ::lPopup   = lPopup
   ::l2007    = .F.       // new
   ::l2010    = .F.       // new

   if lPopup
      // Windows does not provides a way of storing only Popups in resources
      // so we are going to create one on the fly copying it from the
      // one placed at resources
      ::hMenu = CreatePopupMenu()
      MenuClone( ::hMenu, hMenu )
      DestroyMenu( hMenu )
   endif

   ResBuild( Self )

return Self


With those changes your example seems to be properly working, thanks!

We will include these changes in the next FWH build.
regards, saludos

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

Re: Menuitem error with SetPrompt

Postby Maurizio » Wed Jul 09, 2014 1:41 pm

Antonio ,


same error , I think that the error is in

METHOD SetPrompt( cPrompt ) CLASS TMenuItem


If( ::oMenu != nil .and. ( ::oMenu:l2007 .OR. ::oMenu:L2010 ), MF_OWNERDRAW, 0 ) )


if I exclude all works
/*
nFlags := nOR( If( ::lActive, MF_ENABLED,;
nOR( MF_DISABLED, MF_GRAYED ) ),;
If( ::lChecked, MF_CHECKED, 0 ),;
If( ::lHelp, MF_HELP, 0 ),;
If( ::lBreak, MF_BREAK, 0 ),;
If( ::oMenu != nil .and. ( ::oMenu:l2007 .OR. ::oMenu:L2010 ), MF_OWNERDRAW, 0 ) )
*/

Regards Maurizio
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Menuitem error with SetPrompt

Postby Antonio Linares » Wed Jul 09, 2014 4:05 pm

Maurizio,

Have you modified both the menu.ch and the menu.prg ? Here it works with no error.

Anyhow, if you send me your menu RC portion, I build it here and send you a screenshot.
regards, saludos

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

Re: Menuitem error with SetPrompt

Postby Antonio Linares » Wed Jul 09, 2014 4:10 pm

The error comes from here:

If( ::oMenu != nil .and. ( ::oMenu:l2007 .OR. ::oMenu:L2010 ), MF_OWNERDRAW, 0 ) )

because l2007 amd l2010 are nil.

With the change for Class TMenu Method Redefine():

::l2007 = .F. // new
::l2010 = .F. // new

those datas are logical and there is no error.
regards, saludos

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

Re: Menuitem error with SetPrompt

Postby Maurizio » Wed Jul 09, 2014 4:35 pm

Same error

This Is c:\fwh\samples\resmenu.prg ( the RC is the same)




Code: Select all  Expand view
// Using PullDown Menus from resources

#include "FiveWin.ch"
#include "ResMenu.ch"           // Some IDs for this Test

static oWnd

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 75 ;
      TITLE "Using Menus from resources" ;
      MENU  BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu, oItem ,oItem2

   DEFINE MENU oMenu RESOURCE "Main"

   REDEFINE MENUITEM oItem ID ID_ABOUT OF oMenu ;
      ACTION MsgInfo( "About FiveWin" )

   REDEFINE MENUITEM oItem2  ID ID_TEST  OF oMenu ;
      ACTION MsgInfo( "Testing Resources PullDown Menus" )

   REDEFINE MENUITEM ID ID_EXIT OF oMenu ACTION oWnd:End()

   REDEFINE MENUITEM ID ID_DELETE OF oMenu ACTION MsgInfo( "ok: Delete" )
   
   
   oItem2:SetPrompt( "Cambiado" )


return oMenu

//----------------------------------------------------------------------------//
   
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Menuitem error with SetPrompt

Postby Antonio Linares » Wed Jul 09, 2014 6:15 pm

Maurizio,

Here it is working fine.

Have you properly implemented the changes that I told you ? Please check them.
regards, saludos

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

Re: Menuitem error with SetPrompt

Postby Antonio Linares » Wed Jul 09, 2014 6:22 pm

Maurizio,

Not a very good quality photo but it is there :-)

Image
regards, saludos

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

Re: Menuitem error with SetPrompt

Postby Antonio Linares » Wed Jul 09, 2014 6:23 pm

Code: Select all  Expand view
function BuildMenu()

   local oMenu, oItem, oItem2

   DEFINE MENU oMenu RESOURCE "Main"

   REDEFINE MENUITEM oItem ID ID_ABOUT OF oMenu ;
      ACTION MsgInfo( "About FiveWin" )

   REDEFINE MENUITEM oItem2 ID ID_TEST  OF oMenu ;
      ACTION MsgInfo( "Testing Resources PullDown Menus" )

   REDEFINE MENUITEM ID ID_EXIT OF oMenu ACTION oWnd:End()

   REDEFINE MENUITEM ID ID_DELETE OF oMenu ACTION MsgInfo( "ok: Delete" )

   oItem2:SetPrompt( "FWH power" )

return oMenu
regards, saludos

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

Re: Menuitem error with SetPrompt - Solved

Postby Maurizio » Thu Jul 10, 2014 7:54 am

Thank Antonio ,
my fault , :wink:

just a question , why

? oMenu:GetMenuItem(ID_TEST):cCaption --->>> About ResMenu Test...


oMenu:GetMenuItem(ID_TEST):cCaption := "FWH power " ERROR

Regards MAurizio
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Re: Menuitem error with SetPrompt - Solved

Postby Antonio Linares » Thu Jul 10, 2014 1:49 pm

Maurizio,

What error you get ?
regards, saludos

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

Re: Menuitem error with SetPrompt - Solved

Postby Maurizio » Thu Jul 10, 2014 2:37 pm

Antonio ,


Error description: Error BASE/1066 Argument error: conditional
TMENUITEM:SETPROMPT( 349 )

If( ::oMenu != nil .and. ( ::oMenu:l2007 .OR. ::oMenu:L2010 ), MF_OWNERDRAW, 0 ) )

because l2007 amd l2010 are nil.

Code: Select all  Expand view
#include "FiveWin.ch"

#define MF_ENABLED       0
#define MF_GRAYED        1
#define MF_DISABLED      2
#define MF_BITMAP        4
#define MF_CHECKED       8
#define MF_POPUP        16  // 0x0010
#define MF_BREAK        64
#define MF_BYPOSITION 1024  // 0x0400
#define MF_SEPARATOR  2048  // 0x0800
#define MF_HELP      16384  // 0x4000
#define MF_HILITE      128  // 0x0080
#define MF_UNHILITE      0
#define MF_OWNERDRAW   256  // 0x0100

static hClass
static aPopups := {}



// Using PullDown Menus from resources

#include "FiveWin.ch"
#include "ResMenu.ch"           // Some IDs for this Test

static oWnd

//----------------------------------------------------------------------------//

function Main()

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 75 ;
      TITLE "Using Menus from resources" ;
      MENU  BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu, oItem ,oItem2

   DEFINE MENU oMenu RESOURCE "Main"

   REDEFINE MENUITEM oItem ID ID_ABOUT OF oMenu ;
      ACTION MsgInfo( "About FiveWin" )

   REDEFINE MENUITEM oItem2  ID ID_TEST  OF oMenu ;
      ACTION MsgInfo( "Testing Resources PullDown Menus" )

   REDEFINE MENUITEM ID ID_EXIT OF oMenu ACTION oWnd:End()

   REDEFINE MENUITEM ID ID_DELETE OF oMenu ACTION MsgInfo( "ok: Delete" )
   
   

?  oMenu:GetMenuItem(ID_TEST):cCaption   // About ResMenu Test...
   oMenu:GetMenuItem(ID_TEST):cCaption :=  "FWH power "  
 
return oMenu




Regards MAurizio
User avatar
Maurizio
 
Posts: 823
Joined: Mon Oct 10, 2005 1:29 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests