MFC CListCtrl how to Display SubItem text with tabulator ?
-
Hi all, I am inserting text to CListCtrl Items with function SetItemText(). The text contains '\t'. I would need to display the text of the subitems with expanded tabulators. Is there a way? I cannot find any hints about this issue. Many Thanks
-
Hi all, I am inserting text to CListCtrl Items with function SetItemText(). The text contains '\t'. I would need to display the text of the subitems with expanded tabulators. Is there a way? I cannot find any hints about this issue. Many Thanks
-
you propose to replace with number of tabs? it's much effort, because I need to loop over the text and replace by different number of tabs (depending on position). further this works only for fix size fonts.
-
you propose to replace with number of tabs? it's much effort, because I need to loop over the text and replace by different number of tabs (depending on position). further this works only for fix size fonts.
Well the issue is quite simple: if the control does not expand them for you, then you will need to do it yourself. You can use the GetTextExtentPoint32 function[^] to calculate the average size of the characters, and use that information to calculate the width of the tabs.
-
Well the issue is quite simple: if the control does not expand them for you, then you will need to do it yourself. You can use the GetTextExtentPoint32 function[^] to calculate the average size of the characters, and use that information to calculate the width of the tabs.
hmm, maybe I do not understand this approach completely! I could calculate the text size and tab position. but when replacing the tab character with a number of blanks, I will not get an accurate tab position. it will looks quite crude over several lines. further I will have additional issues with the blanks, when I want do make in place edititing. Is there any possibility to draw the text of an subitem by myself? e.g. if I would catch a notification message that an subitem needs to be drawn, that I call a function like CDC::TabbedTextOut() ? Thanks again!
-
hmm, maybe I do not understand this approach completely! I could calculate the text size and tab position. but when replacing the tab character with a number of blanks, I will not get an accurate tab position. it will looks quite crude over several lines. further I will have additional issues with the blanks, when I want do make in place edititing. Is there any possibility to draw the text of an subitem by myself? e.g. if I would catch a notification message that an subitem needs to be drawn, that I call a function like CDC::TabbedTextOut() ? Thanks again!
-
Hi all, I am inserting text to CListCtrl Items with function SetItemText(). The text contains '\t'. I would need to display the text of the subitems with expanded tabulators. Is there a way? I cannot find any hints about this issue. Many Thanks
Member 8534035 wrote:
I am inserting text to CListCtrl Items with function SetItemText().
What does the call to
SetItemText()
look like?Member 8534035 wrote:
The text contains 't\'.
What is so special about the letter t followed by a backslash?
Member 8534035 wrote:
I would need to display the text of the subitems with expanded tabulators.
What in the world does this mean?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Member 8534035 wrote:
I am inserting text to CListCtrl Items with function SetItemText().
What does the call to
SetItemText()
look like?Member 8534035 wrote:
The text contains 't\'.
What is so special about the letter t followed by a backslash?
Member 8534035 wrote:
I would need to display the text of the subitems with expanded tabulators.
What in the world does this mean?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
sorry, I was talking about '\t', the ASCII sign for tabulator. If I assign a text with SetItemText() to a CListCtrl item, the tabulator is ignored completely. e.g. "label:\tsome text which should begin at next tabulator position" The CListCtrl is not viewing any spacing for the tabulator.
-
sorry, I was talking about '\t', the ASCII sign for tabulator. If I assign a text with SetItemText() to a CListCtrl item, the tabulator is ignored completely. e.g. "label:\tsome text which should begin at next tabulator position" The CListCtrl is not viewing any spacing for the tabulator.
Member 8534035 wrote:
...the tabulator is ignored completely.
Of course, since it was not meant to handle it as a special case. One solution would be to call
AfxExtractSubString()
to break your source string up into its individual tokens. Then you could callInsertItem()
to insert an item in the list control, followed bySetItemText()
to set the text of subitems."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles