![]() |
Display issue with captions |
Post Reply ![]() |
Author | |
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 871 |
![]() ![]() ![]() ![]() ![]() Posted: 12 February 2008 at 8:58am |
I noticed an inconsistent margin at the top of my task panel that changed with the command I am running (my commands insert groups into the task panel). It turns out that if a group has a caption, but ShowCaption(FALSE) has been called, DrawGroupCaption will return the height of the caption even though the caption is not drawn.
Then when the group is drawn, the top of the group is offset from the top of the task panel by the height of the non-displayed text.
It looks like a bug in the calculation of the (top) group's offset or the panels client area where the group caption height is taken into account even though it is not displayed.
To avoid this display anomoly I am calling SetCaption("") when I don't have a caption to display.
Unbeknown to me was that when a group or item is added, CJ uses the ID and looks up a string in the resource file and then uses any found string as the caption. I was not calling SetCaption("") when I did not want a group header to display and was simply calling ShowCaption(FALSE). Now I know both calls are necessary. To be safe I also call SetCaption("") for an item added to a group since CJ automatically adds the item with an ID of zero and again can find a string in the resource file.
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
too odd. Please attach screenshot what do you see.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 871 |
![]() ![]() ![]() ![]() ![]() |
It's pretty simple to duplicate. Simply add a group using an ID that happens to match the ID of a string in your string table. When the Group ID is set, the code ends up asking MFC to load a string the given ID.
After adding the Group, call ShowCaption(FALSE).
Here are two images from slightly different commands that show the task panel has what appears to be different margins at the top but in reality is due to a difference in loaded modules that have string tables. Both Groups were created with an ID of one. The image on the left is the result of the attempt to load a string with ID of one failing. The one on the right is the result of a string being loaded (the string loaded was actually a filter list for a "file open" dialog box that happens to have an ID of one). To "fix" the issue I now always call SetCaption("") along with ShowCaption(FALSE) after adding a group (and item) when I am not specifically trying to set the caption.
I have found I have to be super careful when working with CJ code due to all the attempts to automatically retrieve strings from a resource file. The other day I had to track down where a tooltip and button caption was coming from for an item added to the ribbon bar. I found that the string was not in the current MFC module state data's resource handle (the one obtained by calling AfxGetResourceHandle) so the system started walking all the modules loaded into the application and eventually found a string with the ID in a module loaded by an add-in that just happened to have a string with the same ID that was meant for a control on one of the add-in's dialog boxes!!
![]() |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hello,
In all default themes we have
if (!pGroup->IsCaptionVisible())
return 0; in DrawGroupCaption. Maybe you added custom theme and don't return 0 if caption is hidden ?
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 871 |
![]() ![]() ![]() ![]() ![]() |
As a matter of fact someone did write a custom theme for us and sure enough when asked to measure (draw is false) they were not checking the cpation visibility (but did when draw was true). I have found and modified the code appropriately.
Thanks for the tip.
|
|
![]() |
|
ricyang ![]() Newbie ![]() Joined: 26 August 2008 Location: China Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
HI, rdhd,
How to make the horizontal center aligning for the icon and text of each gruop items?
Thank you very much?
Ric
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |