Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the CDockablePane caption

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???

like image 768
cigarman Avatar asked Feb 22 '10 17:02

cigarman


3 Answers

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.

like image 176
cigarman Avatar answered Nov 20 '22 17:11

cigarman


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

like image 33
Patrik Avatar answered Nov 20 '22 18:11

Patrik


I had similar problem that after first close of application two panes got same name. I deleted the registry keys, on first start everything was OK, on second I got again the same bug. SetWindowText("MyPane"); in overriden OnSize of pane did the dirty work. It is not the best place for setting the windows caption, but as Colerman stated above SetWindowsText is not working always as it should.

Anyway, when application is started, pane positing process always call OnSize after creation of pane is finished, so for me this dirty hack did the trick.

like image 23
Izzy Avatar answered Nov 20 '22 16:11

Izzy