If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: MDI "More Windows..." dialog

ovidiucucu,
Yes, I understand all of this.
My question though is a little different.

I have MDI application. By default in the MDI application if there are more than 9 windows open, system will show additional menu item "More Windows..." in the "Window" menu in the menu bar.

What I'm interested in is: what id does this newly created menu have?
Then all I will need is to respond to this menu selection with the appropriate dialog.
I don't want to override the system behavior to display this menu every time. I want to keep the system functionality.

Re: MDI "More Windows..." dialog

Originally Posted by OneEyeMan

ovidiucucu,
[...]
I have MDI application. By default in the MDI application if there are more than 9 windows open, system will show additional menu item "More Windows..." in the "Window" menu in the menu bar.

What I'm interested in is: what id does this newly created menu have?
Then all I will need is to respond to this menu selection with the appropriate dialog.

The "More Windows..." menu item value is... 0x0000FF09.
Please don't tell it to anybody! It's one of the most terrible secrets kept by Microsoft...

Now serios, getting rid of some "hacking" methods to find that magic number, we can do the folowing "investigation":

Search in "AFXRES.H" where are usally defined the IDs used by he MFC framework. We can find these menu command IDs:

Bad news: The Windows menu items for activating some open MDI child plus "More Windows..." menu item, are not added by the MFC framework. Also, the corresonding comand IDs are not handled in the MFC freamework, but in default window procedure. Most possible, for that reason, MFC team didn't define IDs for each of them.

Good news: Now we know that in MFC, first ID has AFX_IDM_FIRST_MDICHILD value. Next IDs are in order, incremented by one. If more than 8 MDI child windows are open, the system adds the "More Windows..." menu item having value AFX_IDM_FIRST_MDICHILD + 9.

Re: MDI "More Windows..." dialog

Just to conclude in fewer words:
There is no standard ID for "More Windows..." command.
It depends on value passed in CLIENTCREATESTRUCT::idFirstChild when creating the MDI Client window.
In MFC framework implemetation, the command ID for "More Windows..." menu is AFX_IDM_FIRST_MDICHILD + 9.

Re: MDI "More Windows..." dialog

ovidiucucu,
So how do I determine the id of this menu item in plain Win32 application?
Just scan the "Window" menu till the end if the MDI child list is more than 9?

All I want is to react to the appropriate Windows command and use my own dialog for that.
I know how to make the dialog and all that but what I don't know is what to react to.

Thank you.

[EDIT]
P.S. Or let me ask it a different way. Is there a standard handler for this menu inside Windows? It looks like it as there is no such handler in simple MFC wizard generated code, but it's just MFC...
[/EDIT]

Re: MDI "More Windows..." dialog

First, please let me try to clarify this, which seems to be a little bit confusing:

Originally Posted by OneEyeMan

[...]
Is there a standard handler for this menu inside Windows? It looks like it as there is no such handler in simple MFC wizard generated code, but it's just MFC...

There is not any "standard handler" in Windows. A message handler is an application-defined function designed to "handle" (process) a message (doing something as a response to a message sent to a window).
For example, in a raw-WinAPI program we can have the following:

OnTimer is a handler for WM_TIMER messages. I've called it "OnTimer" just to be asier for anybody to get what that function is doing, not because it is "standard". Someone else can call it "HumptyDumpty", as well.

In MFC there is something similar, except that message handlers are class member functions and MFC Wizard makes our life easier, by "mapping" message handlers with the help of some macros:

Or can override CWnd::WindowProc and map a handler function in a way more similar to that from raw-WinAPI example.
Of course, I'll never do something like that in practice, for an MFC application. It's just an example to demonstrate what I said in the top of this post.

Re: MDI "More Windows..." dialog

ovidiucucu,
That is all correct statements.
However, let me try to clarify what I meant.

Let's say I have a dialog where I have a list box. There are predefined message that is sent to that list box.
One of such messages is LB_SETCURSEL.
Now somewhere, in one of the Windows DLL, there is a predefined handler for that message which will do the following:

1. Search for the string that is passed as a parameter to this message in the inner string container of the list box
2. If the string is found, it will be scrolled into a view and the background of this string will be painted blue (or the predefined themed colour).
3. If the string passed to this message will not be found, nothing happens.

Now, in your (my) program we can override such behavior by defining our own message handler for the LB_SETCURSEL message which might do some additional stuff or just paint the background red or just do some error message if the string passed will not be found. It is up to an application. Nevertheless the default behavior which is defined inside Windows for that message will stay.

Now my question is: Is there a predefined handler that will display "More Windows..." dialog in response to me selecting the menu? If it is - great, it means I don't need to do anything in my app. If it does not exist - I'd like to know what message to connect such a handler on pure Win32 application.

Re: MDI "More Windows..." dialog

[ continued ]

Originally Posted by OneEyeMan

Now my question is: Is there a predefined handler that will display "More Windows..." dialog in response to me selecting the menu? If it is - great, it means I don't need to do anything in my app. If it does not exist - I'd like to know what message to connect such a handler on pure Win32 application.

Of course, there is a predefined handler that will display "More Windows..." dialog somewhere in the default window procedure.
As long as a menu command is sent via WM_COMMAND message, you can change the default by handling WM_COMMAND in your own application-defined window procedure.
Additionally, you have to know the menu item ID (see examples in post #11).

In an MFC application this ID has the value AFX_IDM_FIRST_MDICHILD + 9 (see #7)

In a raw-WinAPI application, it is 9 plus the value of idFirstChild member of CLIENTCREATESTRUCT structure used when your application creates the MDI Client window (also, see #7).

Re: MDI "More Windows..." dialog

[ continued ]

Now, returning a little bit closer to OP problem.
When the user chooses a menu item, the window receives WM_COMMAND notification message, having the menu item identifier in lower word of WPARAM.
So, in a raw-WinAPI program we can handle a given menu item command having, let's say ID_FILE_NEW identifier, as follows:

And again, also here "OnFileNew" isn't "standard". As I said in the previous post, it is possible to map that command in other way.

Nice and easy, like a walking in the park, as long as ID_FILE_NEW has been found in the project's resources.
Otherwise, there's no way, we have to map it manually. The Wizard isn't enough empathic to guess and/or has not a glass ball to see that we want to map a command identifier which isn't present in the project's resources.

This is case of that "More Windows..." menu command, which has not an ID defined in our application's resources. Not even in the MFC framework...
See my earlier posts, #6 and #7.