views:

237

answers:

2

How do I force a refresh the caption of a CDockablePane in the MFC feature pack? I'm working with the tabbed visual studio style example, and I want to change the captions for the tabs.

These seem to be cached somewhere though, as when I change from the defaults, it uses what the app used on it's previous run. I can find nothing in the registry pertaining to this.

I'm modifying the string table IDS_FILE_VIEW and IDS_CLASS_VIEW to set the new captions. I've stepped to the CDockablePane::CreateEx method and the lpszCaption parameter does contain the new caption, but the old caption is still being used.

The new captions don't seem to load until the pane is hidden and shown again. That should be a hint, but I can't figure it out.

Why won't it just use what I pass as the caption to CreateEx???

+2  A: 

In a nutshell, this is a bug in the MFC feature pack -- actually in the BCG Software library. The bug is that you cannot change these captions dynamically. Their answer is "why would you want to do that?"

The captions for tabbed panes in the dockable pane are stored in the registry. The captions used at creation are NOT used if the captions exist in the registry already.

So, the first time you run your application, it will use the captions from the string table. After that, it uses the captions from the registry.

Using the settings created by the AppWizard, the registry settings are at:

HKEY_CURRENT_USER\Software\Local AppWizard-Generated Applications\MyApp\Workspace\DockingManager-128\DockingPaneAndPaneDividers

The value stored in this key is basically a binary file that gets serialized into the panes at start up by the docking manager. The contents aren't documented but you can see what the code is doing in afxdockablepane.cpp.

I hope this helps someone else who comes across this issue.

Coleman
A: 

Hmmm, baybe I misunderstood, but I just call 'SetWindowText' on an instance of CDockablePane. Caption of it changes to what I pass to 'SetWindowText'...

Patrik
Yes, SetWindowText works, but not really as expected. You have to call SetWindowText sometime after Create is called, and it can't be the next call after Create.For instance, the VS example has a function called CreateDockingWindows. Adding a call to SetWindowText in that function (after the appropriate Create) doesn't work.The point of my original post was that the Create function takes a caption parameter that is completely ignored.
Coleman