Bug in mdichild menu [Fixed]

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

Bug in mdichild menu [Fixed]

Post by Enrico Maria Giordano »

This bug is still there (ALT-1 does nothing, ALT-2 open Test&1, mdichild icon vanishes):

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oMenu

    MENU oMenu 2007
        MENUITEM "Test&1" ACTION MSGINFO( "1" )
        MENUITEM "Test&2" ACTION MSGINFO( "2" )
        MENUITEM "Test&3" ACTION MSGINFO( "3" )
    ENDMENU

    DEFINE WINDOW oWnd MDI;
           TITLE "MDI Test";
           MENU oMenu

    ACTIVATE WINDOW oWnd;
             ON INIT CREATECHILD( oWnd )

    RETURN NIL


STATIC FUNCTION CREATECHILD( oMdi )

    LOCAL oWnd, oMenu

    MENU oMenu 2007
        MENUITEM "Changed&1" ACTION MSGINFO( "1" )
        MENUITEM "Changed&2" ACTION MSGINFO( "2" )
        MENUITEM "Changed&3" ACTION MSGINFO( "3" )
    ENDMENU

    DEFINE WINDOW oWnd MDICHILD OF oMdi;
           TITLE "MDI Child Test";
           MENU oMenu

    ACTIVATE WINDOW oWnd;
             VALID !GETKEYSTATE( VK_ESCAPE );
             MAXIMIZED

    RETURN NIL
EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

Enrico Maria Giordano wrote:This bug is still there (ALT-1 does nothing, ALT-2 open Test&1, mdichild icon vanishes):

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oMenu

    MENU oMenu 2007
        MENUITEM "Test&1" ACTION MSGINFO( "1" )
        MENUITEM "Test&2" ACTION MSGINFO( "2" )
        MENUITEM "Test&3" ACTION MSGINFO( "3" )
    ENDMENU

    DEFINE WINDOW oWnd MDI;
           TITLE "MDI Test";
           MENU oMenu

    ACTIVATE WINDOW oWnd;
             ON INIT CREATECHILD( oWnd )

    RETURN NIL


STATIC FUNCTION CREATECHILD( oMdi )

    LOCAL oWnd, oMenu

    MENU oMenu 2007
        MENUITEM "Changed&1" ACTION MSGINFO( "1" )
        MENUITEM "Changed&2" ACTION MSGINFO( "2" )
        MENUITEM "Changed&3" ACTION MSGINFO( "3" )
    ENDMENU

    DEFINE WINDOW oWnd MDICHILD OF oMdi;
           TITLE "MDI Child Test";
           MENU oMenu

    ACTIVATE WINDOW oWnd;
             VALID !GETKEYSTATE( VK_ESCAPE );
             MAXIMIZED

    RETURN NIL
EMG
Enrico, you are right
This old bug is present for me
I have not been forgotten

You can see my first tests

Remove characters of comment in lines 1412 at 1415 in menudraw.c

Code: Select all

       //if( bMdi ) //&& bPrev )
       // {
         //lpdis->rcItem.right -= 57;
       // }
 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

Dear Enrico
When MdiChild is created, locate the SYSMENU icon in the main menu bar. The items in the main menu are renumbered their order to (n + 1), but the menu has already been created before drawing.
The order of creation and in the painting are different
It is a problem that must be fixed in the creation of the table of accelerators

At the moment
STATIC FUNCTION CREATECHILD( oMdi )

LOCAL oWnd, oMenu

MENU oMenu 2007
MENUITEM "Changed&1" ACTION MSGINFO( "1" )
MENUITEM "Changed&2" ACTION MSGINFO( "2" )
MENUITEM "Changed&3" ACTION MSGINFO( "3" )
ENDMENU

DEFINE WINDOW oWnd MDICHILD OF oMdi;
TITLE "MDI Child Test";
MENU oMenu NOSYSMENU

ACTIVATE WINDOW oWnd;
VALID !GETKEYSTATE( VK_ESCAPE );
MAXIMIZED

RETURN NIL
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in mdichild menu

Post by Enrico Maria Giordano »

If I understood correctly, this is not possible as MDICHILDs are dinamically created after the creation of the main MDI window.

EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

Enrico Maria Giordano wrote:If I understood correctly, this is not possible as MDICHILDs are dinamically created after the creation of the main MDI window.

EMG
NO
The problem is with menu and SYSMENU ( locate ) of mdichild
Table of accelerators is created with ( ALT + 1 ) as the first item
As the MENUSYS icon is inserted ( now SYSMENU is first item ), the first item defined in the menu is now the second one (the accelerator table has not been modified), so it appears when you press ALT + 1, the SYSMENU and not the action of item & 1

If you add clausule NOSYSMENU, run OK
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in mdichild menu

Post by Enrico Maria Giordano »

Undestood. But with NOSYSMENU we don't have the three button on the right (minimize, restore and close) anymore. :-(

EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

I know
That's what needs to be solved
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

Fixed for next version
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in mdichild menu

Post by Enrico Maria Giordano »

Unfortunately the bug has moved here (note: MAXIMIZED is commented out):

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oMenu

    MENU oMenu 2007
        MENUITEM "Test&1" ACTION MSGINFO( "1" )
        MENUITEM "Test&2" ACTION MSGINFO( "2" )
        MENUITEM "Test&3" ACTION MSGINFO( "3" )
    ENDMENU

    DEFINE WINDOW oWnd MDI;
           TITLE "MDI Test";
           MENU oMenu

    ACTIVATE WINDOW oWnd;
             ON INIT CREATECHILD( oWnd )

    RETURN NIL


STATIC FUNCTION CREATECHILD( oMdi )

    LOCAL oWnd, oMenu

    MENU oMenu 2007
        MENUITEM "Changed&1" ACTION MSGINFO( "1" )
        MENUITEM "Changed&2" ACTION MSGINFO( "2" )
        MENUITEM "Changed&3" ACTION MSGINFO( "3" )
    ENDMENU

    DEFINE WINDOW oWnd MDICHILD OF oMdi;
           TITLE "MDI Child Test";
           MENU oMenu

    ACTIVATE WINDOW oWnd;
             VALID !GETKEYSTATE( VK_ESCAPE );
//             MAXIMIZED

    RETURN NIL
EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

Enrico,
Explain your problem better with this example
I have tried it and I think it works correctly
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in mdichild menu

Post by Enrico Maria Giordano »

With MAXIMIZED commented out, try pressing ALT-1 and you will see a message with 2 instead of 1.

EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in mdichild menu

Post by cnavarro »

Ok
As I said in previous posts, it is not a problem of the menus, it's of the METHOD Menuchar CLASS TWindow, try with this modification

Code: Select all

                  if Upper( oMenu:oWnd:ClassName() ) == "TMDIFRAME"
                     if Upper( oMenu:oWnd:oWndActive:ClassName() ) == "TMDICHILD" .and. ;
                        lAnd( oMenu:oWnd:oWndActive:nStyle, WS_SYSMENU )
                        if IsZoomed( oMenu:oWnd:oWndActive:hWnd )
                           nPos := n
                        else
                           nPos := n - 1
                        endif
                     else
                        nPos := n - 1
                     endif
                  else
                     nPos := n - 1
                  endif
                  return nMakeLong( nPos, 2 )
 
Last edited by cnavarro on Thu Jun 29, 2017 5:47 pm, edited 1 time in total.
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Post Reply