I am trying to change the docker caption (docked and undocked) and the dock container tab text dynamically from within the view after creation (ie. think of the DockContainer sample, CViewClasses view, to change the above texts, depending on the view selection)
Inspecting CDockContainer::SetTabText() and CDockContainer::SetDockCaption(), these functions set the new value to a class member variable which is only used during the creation or possible during undock and redock, but are not applied instantly to an exisitng dock.
Also looking at CDockContainer::GetContainerFromView and CDockContainer::GetContainerIndex should there be a break in the for loop once the result is found ?
Is it possible to implement this or advise the preferable way to go about this...
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi David,
Thank you very much for the update and the quick response.
With regards to the SetDockCaption() if the text contains an ampersand &, this is transalated to an underscore _ like the menus... I consider this is not the intended behavour here.
With regards to the SetTabText, this works only when SetOwnerDraw(TRUE) otherwise the new text is not taken into account.
With regards to theCDocker::CDockClient i had to expose GetDocker in order to get the docker CDocker* GetDocker() { return m_pDocker; }
Finally from a view (which is not a ported CWnd) i use the following hackish way to access and call CDockContainer functions:
// Assuming hView is the HWND of your non Win32++ view window ... HWNDhContainer=::GetParent(::GetParent(hView));LRESULTresult=::SendMessage(hContainer,UWM_GETCDOCKCONTAINER,0,0);CDockContainer*pContainer=reinterpret_cast<CDockContainer*>(result);// or ...CDockContainer*pContainer=static_cast<CDockContainer*>(GetCWndPtr(::GetParent(::GetParent(hView))));assert(dynamic_cast<CDockContainer*>(pContainer));// Verify in debug mode.pContainer->SetDockCaption(L"*** New caption text ***");
Best regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi David,
I am trying to change the docker caption (docked and undocked) and the dock container tab text dynamically from within the view after creation (ie. think of the DockContainer sample, CViewClasses view, to change the above texts, depending on the view selection)
Inspecting CDockContainer::SetTabText() and CDockContainer::SetDockCaption(), these functions set the new value to a class member variable which is only used during the creation or possible during undock and redock, but are not applied instantly to an exisitng dock.
Also looking at CDockContainer::GetContainerFromView and CDockContainer::GetContainerIndex should there be a break in the for loop once the result is found ?
Is it possible to implement this or advise the preferable way to go about this...
Thank you.
Hi ioannis,
I've updated the CDockContainer code to support the dynamic updating of the dock container's tab text, tab icon and caption.
You can download the latest snapshot from the Code section here on SourceForge.
Best regards,
David
Hi David,
Thank you very much for the update and the quick response.
With regards to the
SetDockCaption()
if the text contains an ampersand&
, this is transalated to an underscore_
like the menus... I consider this is not the intended behavour here.With regards to the
SetTabText
, this works only whenSetOwnerDraw(TRUE)
otherwise the new text is not taken into account.With regards to the
CDocker::CDockClient
i had to expose GetDocker in order to get the dockerCDocker* GetDocker() { return m_pDocker; }
Finally from a view (which is not a ported CWnd) i use the following hackish way to access and call
CDockContainer
functions:Alternatively, I tried something in the lines of the below to get the
CDockConatainer
.So my question is, is there a proper way to find/access the first
CDockContainer
given aHWND
handle.Thank you in advance.
Last edit: ioannis 2024-06-16
Hi ioannis,
The container stays with its docker even when dockers and containers are rearranged. A view also stays with its container.
Assuming the docker has an ID you can do something like this:
Alternatively you could store the docker's pointer or the container's pointer when it is created.
Best regards,
David
Other options are as follows:
Best regards,
David