Menuitem error with SetPrompt - Solved
Posted:
Tue Jul 08, 2014 4:33 pm
by Maurizio
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
Re: Menuitem error with SetPrompt
Posted:
Tue Jul 08, 2014 6:13 pm
by cnavarro
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" )
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 6:52 am
by Maurizio
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
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 1:20 pm
by Maurizio
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
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 1:23 pm
by Antonio Linares
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.
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 1:41 pm
by Maurizio
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
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 4:05 pm
by Antonio Linares
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.
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 4:10 pm
by Antonio Linares
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.
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 4:35 pm
by Maurizio
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
//----------------------------------------------------------------------------//
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 6:15 pm
by Antonio Linares
Maurizio,
Here it is working fine.
Have you properly implemented the changes that I told you ? Please check them.
Re: Menuitem error with SetPrompt
Posted:
Wed Jul 09, 2014 6:22 pm
by Antonio Linares
Maurizio,
Not a very good quality photo but it is there
Re: Menuitem error with SetPrompt - Solved
Posted:
Thu Jul 10, 2014 7:54 am
by Maurizio
Thank Antonio ,
my fault ,
just a question , why
? oMenu:GetMenuItem(ID_TEST):cCaption --->>> About ResMenu Test...
oMenu:GetMenuItem(ID_TEST):cCaption := "FWH power " ERROR
Regards MAurizio
Re: Menuitem error with SetPrompt - Solved
Posted:
Thu Jul 10, 2014 1:49 pm
by Antonio Linares
Maurizio,
What error you get ?
Re: Menuitem error with SetPrompt - Solved
Posted:
Thu Jul 10, 2014 2:37 pm
by Maurizio
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