FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Bugs report & fixes / Informe de errores y arreglos Bug in Menu [Solved]
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in Menu [Solved]
Posted: Mon Jul 28, 2014 05:48 PM
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 (fw): Select all Collapse
#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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Fri Aug 01, 2014 06:08 AM

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 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Menu
Posted: Fri Aug 01, 2014 08:03 AM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Fri Aug 01, 2014 02:51 PM

Enrico,

If we use an accelerator on the menuitem such space will be used, so it does not look wrong to me :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Menu
Posted: Fri Aug 01, 2014 03:09 PM
Antonio,

please try this. The menu item has been enlarged to accomodate the accelerator.

Code (fw): Select all Collapse
#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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Sat Aug 02, 2014 02:37 AM
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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Menu
Posted: Sat Aug 02, 2014 06:49 AM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Sat Aug 02, 2014 09:16 AM

Enrico,

I am going to review its source and find a way to reduce its length :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Sat Aug 02, 2014 08:41 PM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Menu
Posted: Sat Aug 02, 2014 09:32 PM

Antonio,

so let's find those extra spaces! :-)

EMG

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Sun Aug 03, 2014 02:54 AM
Enrico,

Problem found :-)

In Class TWindow lines 1403 please use this code:

Code (fw): Select all Collapse
         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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Menu
Posted: Sun Aug 03, 2014 07:04 AM

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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Menu
Posted: Sun Aug 03, 2014 07:07 AM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in Menu
Posted: Sun Aug 03, 2014 07:13 AM
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 (fw): Select all Collapse
// + 20 introduced due Error on NT on width calculation 1999/05/19


:-)

EMG