Bug in Menu [Solved]

Bug in Menu [Solved]

Postby Enrico Maria Giordano » Mon Jul 28, 2014 5: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: Select all  Expand view  RUN
#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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Fri Aug 01, 2014 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Fri Aug 01, 2014 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Fri Aug 01, 2014 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Fri Aug 01, 2014 3:09 pm

Antonio,

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

Code: Select all  Expand view  RUN
#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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Sat Aug 02, 2014 2:37 am

Enrico,

This is the menu image without accelerators:

Image

And this is your seocnd example with accelerator:

Image

If you think that they are too large, we could try to implement a MENU ... SIZE clause
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Sat Aug 02, 2014 6: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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Sat Aug 02, 2014 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Sat Aug 02, 2014 9:24 am

Antonio,

thank you! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Sat Aug 02, 2014 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Sat Aug 02, 2014 9:32 pm

Antonio,

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Sun Aug 03, 2014 2:54 am

Enrico,

Problem found :-)

In Class TWindow lines 1403 please use this code:

Code: Select all  Expand view  RUN
        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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Sun Aug 03, 2014 7: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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Menu

Postby Antonio Linares » Sun Aug 03, 2014 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Menu

Postby Enrico Maria Giordano » Sun Aug 03, 2014 7: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: Select all  Expand view  RUN
// + 20 introduced due Error on NT on width calculation 1999/05/19


:-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 1 guest