Click here to Skip to main content
15,116,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My app uses MDI child windows to create GUI objects that are used by another app. The window title texts are considered part of the object and are stored in the document. The MFC framework ovewrites the title text with the document file name, but I managed to foil that by using OnDocumentEvent() to restore the proper text. Now I want to be able to run a dialog to edit the text on some mouse action, e.g. double-click or right-click, on the window title bar. I tried OnNcRButtonDown() but it never gets called, except for clicks on the narrow (2 or 3 pixels) strip between the client area and the window border. Grateful for any ideas on how to trap clicks on the title bar itself.

In case it's relevant, I'm developing with VS 2010 Pro 4.0 under Windows 7.

This should help you out:

You should call the default implementation/windows procedure and inspect the result

Espen Harlinn
Thanks for that hint, Espen, which ultimately led me to the answer...

I tried what you said, which didn't really get me anywhere, as the result of the base class call to OnNcHitTest() returned a value of 18 = HTBORDER = "In the border of a window that does not have a sizing border". This just confirmed what I knew already. However, it did give me the idea of using Spy++, which showed plenty of WM_NCHITTEST messages, only they were being sent to the _parent_ of my view window.

This is no doubt all pretty obvious stuff to people who are familiar with MFC apps, but I'll spell it out here in case anyone else has a related problem:

Your MDI view window is not a child of the main frame, but of an intermediate frame window. This frame window is created dynamically, typically by a call in the app InitInstance() to AddDocTemplate, passing a new CMultiDocTemplate. The third argument to the constructor of CMultiDocTemplate defines the class for your MDI child view frame windows. The standard one is CMDIChildWnd, which works in most cases, but if you want to do any fancy stuff, to process the messages for the child frame you need to derive your own class from CMDIChildWnd and pass that instead to the constructor of CMultiDocTemplate.
Espen Harlinn 1-Jan-11 13:28pm
Glad to be of help, I assumed you where already deriving from CMDIChildWnd ..., happy new year!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900