Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Task Panel
  New Posts New Posts RSS Feed - Display issue with captions
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Display issue with captions

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: Display issue with captions
    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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 February 2008 at 12:26pm
Hi,
 
too odd. Please attach screenshot what do you see.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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!!
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
ricyang View Drop Down
Newbie
Newbie


Joined: 26 August 2008
Location: China
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote ricyang Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.