Menuwidth

Menuwidth

Postby byte-one » Fri Jan 20, 2017 9:03 am

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!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menuwidth

Postby cnavarro » Fri Jan 20, 2017 12:36 pm

Yes, you are right
I will look at it
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: Menuwidth

Postby cnavarro » Sat Jan 21, 2017 7:16 pm

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
 
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: Menuwidth

Postby richard-service » Sun Jan 22, 2017 1:21 am

Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Menuwidth

Postby cnavarro » Sun Jan 22, 2017 1:45 am

Richard, I have not forgotten
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: Menuwidth

Postby richard-service » Sun Jan 22, 2017 8:21 am

cnavarro wrote:Richard, I have not forgotten


I saw it. Thank you so much.
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: Menuwidth

Postby byte-one » Sun Jun 04, 2017 3:20 pm

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!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menuwidth

Postby cnavarro » Mon Jun 05, 2017 1:58 am

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

//----------------------------------------------------------------------------//
 
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: Menuwidth

Postby byte-one » Mon Jun 05, 2017 9:55 am

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}
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menuwidth

Postby cnavarro » Mon Jun 05, 2017 10:42 am

You say, that in a popup menu all items new created every call!?


Let me try to assure you that this is so
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: Menuwidth

Postby cnavarro » Mon Jun 05, 2017 2:30 pm

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

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

 
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: Menuwidth

Postby James Bott » Mon Jun 05, 2017 4:12 pm

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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Menuwidth

Postby cnavarro » Mon Jun 05, 2017 4:16 pm

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 ) ...
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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 114 guests