Vivek Kumar
Vivek Kumar

Reputation: 5040

Updating CMDIChildWnd title in MFC

I am using SetWindowText() of CMDIChildWnd from CScrollView for setting the title from , when I open a document. But title did not get updated, untill I click on the image or when I minimize the application.

I have tried with calling Invalidate(), UpdateWindow() but none of these are working, but I anyhow need to update the title.

Can anyone please let me know how can I do this.

Thanks!

Upvotes: 0

Views: 1681

Answers (1)

Joseph Willcoxson
Joseph Willcoxson

Reputation: 6040

Call the documents SetTitle() method with the title you want. SetTitle() will call CDocument::UpdateFrameCounts(), UpdateFrameCounts() will call the CMDIChildWnd::OnUpdateFrameTitle(TRUE) which will update your frame.

I would think SetWindowText() would work, but it might be that OnUpdateFrameTitle() is getting called afterwards because of UI updating or something, and that OnUpdateFrameTitle() is setting the title back to what it was. Try a breakpoint in CMDIWHildWnd::OnUpdateFrameTItle() or in the CMDIFrameWnd version as well.

Upvotes: 2

Related Questions