Page 1 of 2
Bug in Menu [Solved]
Posted: Mon Jul 28, 2014 5:48 pm
by Enrico Maria Giordano
The horizontal menu size ("This is a test" item) is too much for the string it contains. I remember it was right in the far past. This is a sample:
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oWnd, oMenu
MENU oMenu
MENUITEM "Test"
MENU
MENUITEM "This is a test"
ENDMENU
ENDMENU
DEFINE WINDOW oWnd;
MENU oMenu
ACTIVATE WINDOW oWnd
RETURN NIL
EMG
Re: Bug in Menu
Posted: Fri Aug 01, 2014 6:08 am
by Antonio Linares
Enrico,
It seems fine to me.
When you say "in the far past" which FWH version do you mean ?
I mean, how far is that far past ?
Re: Bug in Menu
Posted: Fri Aug 01, 2014 8:03 am
by Enrico Maria Giordano
Antonio,
sorry, I don't remember.
Anyway, don't you see the extra space between the end of the string and the end of menu? It looks a bit... excessive.
EMG
Re: Bug in Menu
Posted: Fri Aug 01, 2014 2:51 pm
by Antonio Linares
Enrico,
If we use an accelerator on the menuitem such space will be used, so it does not look wrong to me
Re: Bug in Menu
Posted: Fri Aug 01, 2014 3:09 pm
by Enrico Maria Giordano
Antonio,
please try this. The menu item has been enlarged to accomodate the accelerator.
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oWnd, oMenu
MENU oMenu
MENUITEM "Test"
MENU
MENUITEM "This is a test" + CHR( 9 ) + "CTRL-X"
ENDMENU
ENDMENU
DEFINE WINDOW oWnd;
MENU oMenu
ACTIVATE WINDOW oWnd
RETURN NIL
EMG
Re: Bug in Menu
Posted: Sat Aug 02, 2014 2:37 am
by Antonio Linares
Enrico,
This is the menu image without accelerators:
And this is your seocnd example with accelerator:
If you think that they are too large, we could try to implement a MENU ... SIZE clause
Re: Bug in Menu
Posted: Sat Aug 02, 2014 6:49 am
by Enrico Maria Giordano
Antonio,
the current size is double of the item string lenght and this is too much. Please try to right click on the desktop or on any other place and you'll see that the standard menu width is smaller than the FWH menu one.
EMG
Re: Bug in Menu
Posted: Sat Aug 02, 2014 9:16 am
by Antonio Linares
Enrico,
I am going to review its source and find a way to reduce its length
Re: Bug in Menu
Posted: Sat Aug 02, 2014 9:24 am
by Enrico Maria Giordano
Antonio,
thank you!
EMG
Re: Bug in Menu
Posted: Sat Aug 02, 2014 8:41 pm
by Antonio Linares
Enrico,
After answering you, I realized that that menu is not ownerdraw so we don't control at all its painting. Unless we are adding somewhere some spaces, I don't see how we could change its width.
Re: Bug in Menu
Posted: Sat Aug 02, 2014 9:32 pm
by Enrico Maria Giordano
Antonio,
so let's find those extra spaces!
EMG
Re: Bug in Menu
Posted: Sun Aug 03, 2014 2:54 am
by Antonio Linares
Enrico,
Problem found
In Class TWindow lines 1403 please use this code:
Code: Select all
MenuMeasureItem( pMitStruct,;
0.9 * GetTextWidth( 0, If( ! Empty( oItem:cPrompt ),;
StrTran( oItem:cPrompt, "&", "" ), "" ) ) + ;
If( oItem:oMenu:hMenu != If( ::oMenu != nil, ::oMenu:hMenu, 0 ), ;
If( ValType( oItem:cPrompt ) == "C", 50, 0 ), 0 ),;
Empty( oItem:cPrompt ) )
Simply replace that 50 with different values until you find the right size for you. I guess we could set this as a DATA of Class TMenu.
Re: Bug in Menu
Posted: Sun Aug 03, 2014 7:04 am
by Enrico Maria Giordano
Antonio,
great! I'm going to make some test. Anyway, I think you can simply check the context menu (right click) of the desktop or other Windows items.
EMG
Re: Bug in Menu
Posted: Sun Aug 03, 2014 7:07 am
by Antonio Linares
Enrico,
As we don't have time to implement a new clause as FWH 14.07 is almost ready and it is not the time to make deep changes, if you suggest me the right size, then I will include it in FWH 14.07
Re: Bug in Menu
Posted: Sun Aug 03, 2014 7:13 am
by Enrico Maria Giordano
Antonio,
I just tested your change and it's fine for me. Many thanks. By the way, I found this comment in window.prg that explains all:
Code: Select all
// + 20 introduced due Error on NT on width calculation 1999/05/19
EMG