Page 1 of 1

Menuwidth

PostPosted: Fri Jan 20, 2017 9:03 am
by byte-one
If i set a new text for a menuitem with
Code: Select all  Expand view
oMenu:aMenuItems[x]:setprompt("???")
the width of the menu is not changed according the new text. What to do? The correction should be make automatically!

Re: Menuwidth

PostPosted: Fri Jan 20, 2017 12:36 pm
by cnavarro
Yes, you are right
I will look at it

Re: Menuwidth

PostPosted: Sat Jan 21, 2017 7:16 pm
by cnavarro
New METHOD SetChangePrompt( cPrompt ) for change prompt of item

Also for the next version

New:
Implemented definition of prompts items menus with codeblock or array values

Code: Select all  Expand view

            MENUITEM { "Prompt", "Array", "Definition" } ACTION MsgInfo( "Fichero de Zonas" )
            MENUITEM { || "CodeBlock Definition" }

 


Also implemented modification prompt with codeblock or array values
Code: Select all  Expand view

            MENUITEM "Change Prompt SubMenu-2 ( Item 7 ) - Array" ;
               ACTION ( oMnu:aMenuItems[ 2 ]:bAction:aMenuItems[ 7 ]:SetChangePrompt( {"Lunes", "Martes", "Miercoles", "Jueves" } ) )
            SEPARATOR
            MENUITEM "Change Prompt SubMenu-2 ( Item 8 ) - CodeBlock" ;
               ACTION ( oMnu:aMenuItems[ 2 ]:bAction:aMenuItems[ 8 ]:SetChangePrompt( { || "Codeblock assigned" } ) )

 


New
Method RestorePrompt ( at previous value )
Usage: oItem:RestorePrompt()

Code: Select all  Expand view

            MENUITEM "Restore Prompt Menu" ACTION oMnu:aMenuItems[ 2 ]:RestorePrompt()
            SEPARATOR
 

Re: Menuwidth

PostPosted: Sun Jan 22, 2017 1:21 am
by richard-service

Re: Menuwidth

PostPosted: Sun Jan 22, 2017 1:45 am
by cnavarro
Richard, I have not forgotten

Re: Menuwidth

PostPosted: Sun Jan 22, 2017 8:21 am
by richard-service
cnavarro wrote:Richard, I have not forgotten


I saw it. Thank you so much.

Re: Menuwidth

PostPosted: Sun Jun 04, 2017 3:20 pm
by byte-one
I am testing:
Code: Select all  Expand view
oMenu1:aMenuItems[2]:SetChangePrompt ( "Newname" )

The width of the menu changes NOT according to the longest menuitem of the oMenu1. If the new prompt is longer then the old prompt, the menutext is not to see full!

Re: Menuwidth

PostPosted: Mon Jun 05, 2017 1:58 am
by cnavarro
Günther
When an item is painted, it is not possible to modify its dimensions ( for now ).
Please try this sample with this instructions:
Execute sample and
1.- Do not click on the main menu (neither the first item nor the second item)
2.- Click the "Change Prompt" button
3.- Click on the second item in the main menu and see the change in the prompt
4.- Now, click on the item ("Exit"), and click on the second option "Change Prompt SubMenu-1 to Array"
5.- Click on the first item in the main menu and see the change in the last item
6.- Click on the "Exit" item and select the first option: you will see that the second prompt has changed but not its dimensions even though the Drawmenubar statement is executed.

All right
Now restart the program

1.- Click on the menu and see all the submenus
Repeat the process from the point 2.- above

I have been investigating this problem for a while, but there is no function to refresh the menu. There is no information in the windows documentation about it.
But I'm still with it

This problem only occur with menu bar, not with popupmenu ( These menus are created and destroyed every time )

Regards

Code: Select all  Expand view


#include "Fivewin.ch"

//----------------------------------------------------------------------------//
//
// Test change prompt menuitem
//
//----------------------------------------------------------------------------//

Static oWnd
Static oFont
Static nHFont
Static cFont
Static lVar   := .F.

Function Main()
   
   local oF1
   local oBtn

   cFont    := "Verdana"
   nHFont   := 14
   DEFINE FONT oFont NAME cFont SIZE 0, -nHFont
   DEFINE WINDOW oWnd ;
      TITLE " Test Menu change and Evaluate Prompts " + "   - Ver.: " + FWVERSION + if( IsExe64(), ;
            "  ( 64", "  ( 32" ) + " bits ) - " + FWString( "User" ) + ;
            ": " + WNetGetUser() + " - " + hb_Compiler() ;
      MENU MenuSal() ;
      COLOR CLR_WHITE, METRO_STEEL
     
   @ 400, 300 BUTTON oBtn PROMPT "Change" PIXEL SIZE 100, 60 ;
   ACTION ( lVar  := !lVar, oWnd:oMenu:aMenuItems[ 2 ]:bAction:aMenuItems[ 3 ]:SetChangePrompt( "Prompt more long 1234567890" ) )
   @ 400, 500 BUTTON oBtn PROMPT "Restore" PIXEL SIZE 100, 60 ;
      ACTION oWnd:oMenu:aMenuItems[ 2 ]:bAction:aMenuItems[ 3 ]:RestorePrompt()

   ACTIVATE WINDOW oWnd MAXIMIZED
   RELEASE FONT oFont

Return nil

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

Function MenuSal()

   local oMnu
   local oMnu1
   local oldMnu

   MENU oMnu  NOBORDER OF oWnd 2013 //FONT oFont

      MENUITEM "Datos"
         MENU
            MENUITEM "Test old SetPrompt" ;
               ACTION  ( oMnu:aMenuItems[ 2 ]:bAction:aMenuItems[ 3 ]:SetPrompt( "PPPPPPPPPPPPPPPPPPPP" ) )
            SEPARATOR
            MENUITEM { "Prompt", "Array", "Definition" } ACTION MsgInfo( "Fichero de Zonas" )
            MENUITEM { || "CodeBlock Definition" }
            MENUITEM "Tools"
            MENU oMnu1
               MENUITEM "Copia de Seguridad"
               MENUITEM "Herramientas"
               SEPARATOR
               MENUITEM "Otros"
            ENDMENU
         ENDMENU
      MENUITEM "Otros Items"
         MENU
            MENUITEM { || If( lVar, "TRUE", "FALSE" ) }
            SEPARATOR
            MENUITEM "Item_7" ACTION MsgInfo( "Item_7" )
         ENDMENU
      MENUITEM "Exit"
         MENU
            MENUITEM "Change Prompt Menu Bar" ACTION ( oMnu:aMenuItems[ 2 ]:SetChangePrompt( "Prompt Changed" ), DrawMenuBar( oWnd:hWnd ) )
            SEPARATOR
            MENUITEM "Change Prompt SubMenu-1 to Array" ;
               ACTION ( oMnu:aMenuItems[ 1 ]:bAction:aMenuItems[ 5 ]:SetChangePrompt( { "A", "B", "C", 4, "5" } ) )
            SEPARATOR
            MENUITEM "Exit Test" ACTION oWnd:End()
         ENDMENU
   ENDMENU
                                                           
Return oMnu

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

Re: Menuwidth

PostPosted: Mon Jun 05, 2017 9:55 am
by byte-one
Thanks for your help!

I have a POPUP - Menue in a button from a ribbonbar. You say, that in a popup menu all items new created every call!? Must the creation from the menu made in a separate function?

Code: Select all  Expand view
@ C_RANDV,C_RANDH+(C_STEPH_MID) ADD BUTTON oBtVer1 PROMPT "Wettbewerb" MENU oMenu1 GROUP oGrp POPUP C_TBUTTFORM_MID BITMAP "ver_1" MESSAGE "Ergebnis(se) in Wettbewerb übertragen" TOOLTIP {"Ergebnis(se) in Wettbewerb übertragen",TX_TOOLTIP_M}

Re: Menuwidth

PostPosted: Mon Jun 05, 2017 10:42 am
by cnavarro
You say, that in a popup menu all items new created every call!?


Let me try to assure you that this is so

Re: Menuwidth

PostPosted: Mon Jun 05, 2017 2:30 pm
by cnavarro
This is a sample
Code: Select all  Expand view


#include "FiveWin.ch"

static oWnd, oMenu, lVar := .F.

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

function Main()

 local oBtn
 
 DEFINE WINDOW oWnd ;
    FROM 1, 1 TO 20, 65 ;
    TITLE "FiveWin - Testing Popup Menus"

 SET MESSAGE OF oWnd TO "Press Mouse Left Button to activate the Popup"

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

return nil

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

function BuildPopup()

   MENU oMenu POPUP                             // Creating a POPUP
      MENUITEM "Open"
      MENU
         MENUITEM "Change" MESSAGE "New whatever..." ACTION BuildPopup()
         SEPARATOR
         MENUITEM "Get" ;
            MESSAGE "Get whatever..." ;
            ACTION cGetFile( "Clipper DataBase (*.dbf) | *.dbf |" + ;
                             "Paradox DataBase (*.db) | *.db",;
                             "Please Select" )
      ENDMENU
      MENUITEM "Close"
      MENU
         MENUITEM "New..."
         SEPARATOR
         MENUITEM "Old..."
      ENDMENU
      MENUITEM "Select" MESSAGE "Select whatever..."
      MENUITEM "All" ACTION MsgInfo( "Todo" ) MESSAGE "Everything"
      SEPARATOR
      MENUITEM "More..." ACTION MsgInfo( "More" ) ;
         MESSAGE "This is just an example"
   ENDMENU

return oMenu

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

function ShowPopup( nRow, nCol )

   BuildPopup()
   if !lVar
      lVar   := !lVar
   else
      oMenu:aMenuItems[ 2 ]:SetChangePrompt( "Prompt more long 1234567890" )
   endif

   ACTIVATE POPUP oMenu WINDOW oWnd AT nRow, nCol

return nil

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

 

Re: Menuwidth

PostPosted: Mon Jun 05, 2017 4:12 pm
by James Bott
Günther,

Maybe as a workaround you could make the one of the original menu items longer by adding trailing spaces. Make it long enough to handle the replacement menu item.

Just a thought.

James

Re: Menuwidth

PostPosted: Mon Jun 05, 2017 4:16 pm
by cnavarro
James Bott wrote:Günther,

Maybe as a workaround you could make the one of the original menu items longer by adding trailing spaces. Make it long enough to handle the replacement menu item.

Just a thought.

James


In that case, better add Chr (9) character

MENUITEM "Prompt 1" + Chr( 9 ) + Chr( 9 ) ...