Still using VS 2008, I have split my MDI view class in my CChildFrame
to facilitate a navigation sidebar (a CListCtrl
) next to my old CScrollView
using a static splitter (source code). This however implied two side effects: Beside the mouse wheel no longer working (where I found a workaround for), the application window is no longer updated on SetPathName()
. What do I need to do to bridge the splitter so the framework updates the application window again based on my CDocument
?
Asked
Active
Viewed 114 times
1

thomiel
- 2,467
- 22
- 37
-
1Where do you call SetPahName()? And style FWS_ADDTOTITLE must be set. – Tom Tom Feb 14 '21 at 08:57
-
1FWS_ADDTOTITLE is set in the frame. Before I applied the splitter, it worked, as FWS_ADDTOTITLE is default in a MDI app. I tried to call CSplitterWnd::CreateStatic() with it, but it didn't change anything. SetPahName() is being called in my CDocument class, e.g. in OnNewDocument() or in OnFileSaveAs(). – thomiel Feb 15 '21 at 13:14
-
On your MainFrame class, just put a method `void CMyFrame::OnUpdateFrameTitle(BOOL bAddToTitle) { __super::OnUpdateFrameTitle(bAddToTitle); }` and a breakpoint there, to see what happens. If needed, you will have to provide your own override instead of calling the `__super` implementation. – sergiol Feb 15 '21 at 14:08
-
After a lengthy bisect search, I got the window titles back to normal after commenting out the `FWS_ADDTOTITLE` style, I must have added in `PreCreateWindow()` after TomTom's comment. I can't recover all the other changes I made. One of them must have solved the document title problem... – thomiel Mar 02 '21 at 16:36
1 Answers
1
On your MainFrame class, just put a method
void CMyFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
__super::OnUpdateFrameTitle(bAddToTitle);
}
and a breakpoint there, to see what happens. If needed, you will have to provide your own override instead of calling the __super
implementation.

sergiol
- 4,122
- 4
- 47
- 81
-
When querying `GetActiveDocument()` in `CMDIFrameWnd::OnUpdateFrameTitle` it always return NULL. So replacing my `CScrollView` with a `CSplitterWnd` with two `CView`-derived classes somehow broke the connection of the document and the framework. This was due to `CFrameWnd::GetActiveView()` never revealed an active view. I also added a `SetActivePane()` and `SetActiveView()` in `CChildFrame::OnCreateClient` but it didn't change anything. – thomiel Feb 15 '21 at 14:27
-
PS: `CMainFrame::OnUpdateFrameTitle()` is being called several times, after adding the override. There is still just the application name displayed in the windows title without the document name. – thomiel Feb 15 '21 at 14:39
-
-
I dug as far as I could. The question is: Where do I have to override what function to have the active document set, so that it can be found by the framework again, without having to read the complete MFC source code? – thomiel Feb 15 '21 at 14:43
-
Put a breakpoint on your `CFrameWnd::GetActiveDocument` function : https://i.imgur.com/WaLX09m.png to see what is getting returned. – sergiol Feb 15 '21 at 15:51
-
Gets a valid document via `CMDIFrameWnd::OnUpdateFrameTitle()` but I noticed it won't pass this check `if (pActiveChild != NULL && (pActiveChild->GetStyle() & WS_MAXIMIZE) == 0)` as the window style obviously doesn't indicate that the window is maximized. Ironically, if I normalize the MDI child windows, the application window gets the document name, but the child windows don't have a title. I also remember that after adding the splitter, the child window started normalized (maximised before) and I had to call `CMDIChildWndEx::ActivateFrame(SW_SHOWMAXIMIZED)` in `CChildFrame::ActivateFrame`. – thomiel Feb 16 '21 at 11:38