Opened 9 years ago

Closed 2 years ago

#3295 closed defect (fixed)

"More Windows" MDI Window menu item doesn't work

Reported by: minhtri Owned by: vadz
Priority: normal Milestone: 2.9.5
Component: wxMSW Version:
Keywords: mdi Cc: minhtri, hockkn
Blocked By: Blocking:
Patch: yes

Description

report by Minhtri Pham.
pham_minh_tri@…

In MDI application ( wxMDIParentFrame and
wxMDIChildFrame), when there are more than 10 child
windows open, select Window -> More Windows... , the
focus to the current child window is lost. When cancel
button on the "Select Windows" dialog is press , the
focus is change to the difference windows. Happen in
version 2.6.3

Attachments (2)

3295.patch download (896 bytes) - added by oneeyeman 2 years ago.
Patch to resolve ticket
test.cpp download (13.0 KB) - added by oneeyeman 2 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 2 years ago by oneeyeman

This is still reproducible.
However it is currently worth.

I have Windows 7 64-bit + MSVC 2010.

  1. Build and run mdi sample
  2. Create 11 children
  3. Observe that the window11 is active and has focus
  4. Select "More Windows..."

No dialogs for window selection appear. Instead the different window from the one that was active becomes active (i.e. window 9).

comment:2 Changed 2 years ago by vadz

  • Keywords mdi added
  • Status changed from new to confirmed
  • Summary changed from Child windows is lost focus in MDI to "More Windows" MDI Window menu item doesn't work

That's because we don't provide any special handler for "More Windows..." menu item and just handle it as selecting the 10-th window. It's not clear to me if DefFrameProc() is supposed to take care of it automatically, but apparently not because if we don't process it at all, i.e. apply this patch:

  • src/msw/mdi.cpp

    diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp
    index 46e0166..e154a0d 100644
    a b  
    6262// constants 
    6363// --------------------------------------------------------------------------- 
    6464 
    65 // This range gives a maximum of 500 MDI children. Should be enough :-) 
    66 const int wxFIRST_MDI_CHILD = 4100; 
    67 const int wxLAST_MDI_CHILD = 4600; 
     65// ID of the first child window, the other children are assigned subsequent 
     66// values. 
     67const int wxID_FIRST_MDI_CHILD = 4100; 
    6868 
    6969// The MDI "Window" menu label 
    7070const char *WINDOW_MENU_LABEL = gettext_noop("&Window"); 
    inline HMENU GetMDIWindowMenu(wxMDIParentFrame *frame) 
    118118    EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) 
    119119 
    120120#if wxUSE_MENUS 
    121     EVT_MENU_RANGE(wxFIRST_MDI_CHILD, wxLAST_MDI_CHILD, 
     121    // There can be only 9 menu items in the "Window" menu, if there are 10 or 
     122    // more MDI children we get a "More windows" menu item. 
     123    EVT_MENU_RANGE(wxID_FIRST_MDI_CHILD, wxID_FIRST_MDI_CHILD + 8, 
    122124                   wxMDIParentFrame::OnMDIChild) 
    123125    EVT_MENU_RANGE(wxID_MDI_WINDOW_FIRST, wxID_MDI_WINDOW_LAST, 
    124126                   wxMDIParentFrame::OnMDICommand) 
    bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) 
    13031305    m_parent = parent; 
    13041306 
    13051307    ccs.hWindowMenu = GetMDIWindowMenu(parent); 
    1306     ccs.idFirstChild = wxFIRST_MDI_CHILD; 
     1308    ccs.idFirstChild = wxID_FIRST_MDI_CHILD; 
    13071309 
    13081310    DWORD msStyle = MDIS_ALLCHILDSTYLES | WS_VISIBLE | WS_CHILD | 
    13091311                    WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 

then nothing happens when this item is selected.

We probably should show our own dialog allowing to select the MDI child.

comment:3 Changed 2 years ago by oneeyeman

Vadim,
Will it be just generic dialog for all platforms? Or they will be different?

BTW, is there an MDI concept under OS X? I think it's just Windows/Linux specific.

comment:4 Changed 2 years ago by vadz

The menu under other platforms doesn't have "More Windows" item so it's Windows-only. The real problem is to understand whether we're really supposed to implement it or if there is a built-in dialog which should be shown but is not for some reason.

comment:5 Changed 2 years ago by oneeyeman

Vadim,
That very interesting observation. Which platform/compiler did you use to test the patch?

According to this "More Windows..." is supplied by the system and it should be handled by the DefWindowProc of MDIParentFrame.

I just did a quick MFC MDI test program and nowehere in the sources code I see such a menu or a handler. Checking with SPY++ I see following:

S WM_EXITMENULOOP flsTrackPopupMenu: False
R WM_EXITMENULOOP
P WM_COMMAND wNotifyCode:0 (sent from a menu) wID: 65289
S WM_CANCELMODE
R WM_CANCELMODE

I think that this 65289 is the code that is handled by the Windows DefWindowProc to show the "More Windows..." dialog.

The test was done under WinXP SP2 with VC6.

comment:6 follow-up: Changed 2 years ago by vadz

I really don't see what can this have to do with the compiler version but FWIW I used VC9 under Win7.

The thing to do would be to find a small MDI sample/example (Microsoft surely has one somewhere) and see if this dialog is shown automatically for it or not.

comment:7 in reply to: ↑ 6 Changed 2 years ago by oneeyeman

Vadim,
Replying to vadz:

I really don't see what can this have to do with the compiler version but FWIW I used VC9 under Win7.

The thing to do would be to find a small MDI sample/example (Microsoft surely has one somewhere) and see if this dialog is shown automatically for it or not.

Yes, if we don't process the message then the bug does not occur but the standard window selection dialog does not show up as well. Will try to investigate more.

Changed 2 years ago by oneeyeman

Patch to resolve ticket

comment:8 Changed 2 years ago by oneeyeman

  • Patch set

Attached please find the patch that implements the standard Windows MDI "More Windows..." dialog.
This implementation does not expose this functionality to the user so (s)he is not able to reimplement this in his code.

comment:9 Changed 2 years ago by oneeyeman

Vadim,
Did you look at this patch?
I built a Win32 MDI application (not an MFC one), confirmed that the default handler for that menu exist and came up with this patch.

Now the question is: do we need to expose this functionality so that the user can create his own "More Windows..." dialog, Just like Visual Studio does? Or we should just simply let standard handler do it work and forget about it?

comment:10 Changed 2 years ago by vadz

  • Milestone set to 2.9.5
  • Owner set to vadz
  • Status changed from confirmed to accepted

Changed 2 years ago by oneeyeman

comment:11 Changed 2 years ago by oneeyeman

Attached please find Win32 code I tested against.

comment:12 Changed 2 years ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [73398]) Make "More windows..." menu item in MDI "Window" menu work in wxMSW.

Don't interpret the commands from this menu item as child window selection.

Closes #3295.

Note: See TracTickets for help on using tickets.