If the text from a menuitem has changed to a longer text, the width from the menu should also be widther! (vis versa on a shorter text!)
If the text from a menuitem has changed to a longer text, the width from the menu should also be widther! (vis versa on a shorter text!)
From METHOD DrawItem( nIdCtl, pItemStruct ) CLASS TWindow we call MenuDrawItem() and we supply the pItemStruct that we receive from Windows.
In such structure there is a value for the right coordinate of the menuitem:
lpdis->rcItem.right
so there we could try to modify it and see if it expands the whole menu size, in example:
lpdis->rcItem.right + 200;
in fact this should be calculated regarding the length of the new text and also the used font.
Will the whole menu repaint just because we modify the size of an item ? I have never tested it.
continues...
Günther,
And what it should had been my first answer to you:
How are you changing the text of the menuitem ? Could you provide a small example ? thanks ![]()
Antonio, thanks for your explanation! I use ::SetPrompt( cPrompt ). The text is changed, but the lenght are the same as before! Should i use refresh()?
Günther,
Do you want that the menu width changes meanwhile the menu is shown ? Or next time is shown ?
Have you considered to provide the menu items an initial longer width so the next text will fit in ?
Do you want that the menu width changes meanwhile the menu is shown ?
Günther
I am thinking that changing the menu text is not a good user interface design. Users get used to menu items and changing them would be confusing--it would be to me.
I don't recall ever having seen this on an off-the-shelf program before.
Perhaps it would be better to have two menu items where one item is always disabled? Or, some similar approach rather than changing the text.
Just a thought.
Regards,
James
Günther,
Could you provide a small PRG example to show how you are doing it ? thanks
local cName := cName1 := "Test" , cName2 := "Long Long Long Long Long Long Long Long Long Test"
MENU oMenu POPUP 2007
MENUITEM "Wettbewerb auswählen" ;
ACTION (cName := if(cName==cName1,cName2,cName1) , oMenu:aMenuItems[2]:setprompt(cName))Günther,
Could you provide a complete PRG ?
Because in your code you are changing the text of a menuitem, but that menuitem is only "alive" meanwhile the popup is in use.
Are you using ACTIVATE POPUP ... SAVE ?
Where are you using such popup from ?
#include "Fivewin.ch"
Static cName1
FUNCTION MAIN()
LOCAL oWnd
cName1 := "Test"
DEFINE WINDOW oWnd
oWnd:bRClicked := { |nRow, nCol, nFlags| MiMenu( oWnd, nRow, nCol ) }
ACTIVATE WINDOW oWnd
RETURN NIL
//----------------------------------------------------------------------------//
Function MiMenu( oWnd, nRow, nCol )
Local oMenu
Local oItem1
Local oItem2
Local oItem3
local cName := "Test"
Local cName2 := "Long Long Long Long Long Long Long Long Long Test"
MENU oMenu POPUP //2007
MENUITEM oItem1 PROMPT "Wettbewerb auswählen" ;
ACTION ( cName1 := if( cName == cName1, cName2, cName ) ,;
oItem2:SetPrompt( cName1 ) ) //oMenu:aMenuItems[2]:setprompt(cName) )
MENUITEM oItem2 PROMPT cName1
SEPARATOR
MENUITEM oITem3 PROMPT "Y OTRO" ACTION MsgInfo( Len( oMenu:aMenuItems ) )
ENDMENU
ACTIVATE POPUP oMenu WINDOW oWnd AT 140, 10
Return oMenu
//----------------------------------------------------------------------------//Where are you using such popup from ?