FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Menuitem error with SetPrompt - Solved
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Menuitem error with SetPrompt - Solved
Posted: Tue Jul 08, 2014 04: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

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuitem error with SetPrompt
Posted: Tue Jul 08, 2014 06: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 (fw): Select all Collapse
        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 (fw): Select all Collapse
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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 06:52 AM
Thank Navarro

but with your workaround I have the same error.

This is from c:\fwh\samples\resmenu.prg
Code (fw): Select all Collapse
// 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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 01:20 PM
Antonio ,

I have the same error with ;

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


Code (fw): Select all Collapse
// 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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 01: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 (fw): Select all Collapse
#xcommand REDEFINE MENUITEM [ <oMenuItem> ] ;
             [ PROMPT <cPrompt> ] ;
             [ ID <nId> <of: OF, MENU> <oMenu> ] ;
             ...


In menu.prg:

Code (fw): Select all Collapse
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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 01: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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 04: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 04: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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 04:35 PM
Same error

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




Code (fw): Select all Collapse
// 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

//----------------------------------------------------------------------------//
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 06: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 06:22 PM
Maurizio,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt
Posted: Wed Jul 09, 2014 06:23 PM
Code (fw): Select all Collapse
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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Menuitem error with SetPrompt - Solved
Posted: Thu Jul 10, 2014 07: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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menuitem error with SetPrompt - Solved
Posted: Thu Jul 10, 2014 01:49 PM

Maurizio,

What error you get ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Menuitem error with SetPrompt - Solved
Posted: Thu Jul 10, 2014 02:37 PM
Antonio ,


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

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

because l2007 amd l2010 are nil.

Code (fw): Select all Collapse
#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