FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Menuwidth
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Menuwidth
Posted: Fri Jan 20, 2017 09:03 AM
If i set a new text for a menuitem with
Code (fw): Select all Collapse
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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: Sat Jan 21, 2017 07: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 (fw): Select all Collapse
            MENUITEM { "Prompt", "Array", "Definition" } ACTION MsgInfo( "Fichero de Zonas" )
            MENUITEM { || "CodeBlock Definition" }


Also implemented modification prompt with codeblock or array values
Code (fw): Select all Collapse
            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 (fw): Select all Collapse
            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
Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: Menuwidth
Posted: Sun Jan 22, 2017 01:21 AM
Best Regards,



Richard



Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 32bit

MySQL v8.0

Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 64bit
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: Sun Jan 22, 2017 01: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
Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: Menuwidth
Posted: Sun Jan 22, 2017 08:21 AM
cnavarro wrote:Richard, I have not forgotten


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



Richard



Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 32bit

MySQL v8.0

Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 64bit
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Menuwidth
Posted: Sun Jun 04, 2017 03:20 PM
I am testing:
Code (fw): Select all Collapse
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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: Mon Jun 05, 2017 01: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 (fw): Select all Collapse
#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
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Menuwidth
Posted: Mon Jun 05, 2017 09: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 (fw): Select all Collapse
@ 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: Mon Jun 05, 2017 02:30 PM
This is a sample
Code (fw): Select all Collapse
#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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Menuwidth
Posted: Mon Jun 05, 2017 04: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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Menuwidth
Posted: Mon Jun 05, 2017 04: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

Continue the discussion