Print Page | Close Window

Display issue with captions

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Task Panel
Forum Description: Topics Related to Codejock Task Panel
URL: http://forum.codejock.com/forum_posts.asp?TID=9567
Printed Date: 06 May 2024 at 2:18am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Display issue with captions
Posted By: rdhd
Subject: Display issue with captions
Date 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.



Replies:
Posted By: Oleg
Date Posted: 12 February 2008 at 12:26pm
Hi,
 
too odd. Please attach screenshot what do you see.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: rdhd
Date Posted: 12 February 2008 at 4:05pm
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!!
 


Posted By: Oleg
Date Posted: 13 February 2008 at 1:20am
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


Posted By: rdhd
Date Posted: 14 February 2008 at 10:23am
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.


Posted By: ricyang
Date Posted: 26 August 2008 at 8:59pm
HI, rdhd,
 
How to make the horizontal center aligning for the icon and text of each gruop items?
 
Thank you very much?
 
Ric



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net