Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: uTextOutColorsTabbed() - default color for selected text? (Read 3178 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

uTextOutColorsTabbed() - default color for selected text?

I'm using custom formatting string with tabulators and colors ($tab(), $rgb()). I use owner-drawing on my DropDown List. Here is part of the code:

Code: [Select]
lpdis = (LPDRAWITEMSTRUCT) lparam;
DWORD defaultColor =
      GetSysColor(lpdis->itemState & ODS_SELECTED ?
      COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
.
.
.
uTextOutColorsTabbed(lpdis->hDC,
      formatted_titles[lpdis->itemID],
      infinite, &(lpdis->rcItem), 2, &(lpdis->rcItem),
      lpdis->itemState & ODS_SELECTED,
      defaultColor,
      true);


formatted_titles[n] is where I store my formatted string, for example:
Code: [Select]
Text_In_Default_Color $rgb(0,255,0) Text_In_Green $tab() RALIGN


The problem is: when the item is not selected - everything is OK. But, when the item is selected, then uTextOutColorsTabbed seems to ignore my defaultColor value and displays text (Text_In_Default_Color here) in black. There is no problem, when I set (BOOL) selected parameter to false (but then the selected color from $rgb(x,y,z,s_x,s_y,s_z) is ignored...)

Am I missing something?...

PS. What is the (BOOL) use_columns parameter for? I can't see the difference when using it or not.

uTextOutColorsTabbed() - default color for selected text?

Reply #1
If selected is true, the function inverts the default background color, so if you want to explicitly set a certain default color for the selected state, you should invert it before passing it to uTextOutColorsTabbed. Example:
Code: [Select]
uTextOutColorsTabbed(hDC, ..., selected, selected ? (selected_color ^ 0xFFFFFF) : normal_color, true);

If use_columns is true, the function behaves as in the Default User Interface playlist, i.e. everything after the last tab is right-aligned, and the other tabs (if any) are used to position left-aligned text at intervals determined by the total number of tabs in the text. If the parameter is false, every tab expands to an equal amount of space. If the text only contains one tab, there is no visible difference. However, try to compare these cases:
Code: [Select]
A$tab(2)B$tab(1)C
AAAA$tab(2)B$tab(1)C
A$tab()B$tab()
0123456789$tab()ABCDEFGHIJ$tab()
A$tab()
$tab()A

The output would vaguely resemble this with use_columns set to false (assumed width is 12 characters):
Code: [Select]
A      B   C
AAAA    B  C
A     B    
0123456789AB
A          
           A

If it is set to true, it would be something like this:
Code: [Select]
A       B  C
AAAA    B  C
A     B    
012345ABCDEF
A          
           A

Note the difference how text is clipped in the fourth line and how the right-aligned text in the first two lines is drawn in the space allocated to the second column with use_columns set to true.

This is from memory; I hope I got the examples right.

 

uTextOutColorsTabbed() - default color for selected text?

Reply #2
Thank you for your explanations, now everything look fine  Indeed, i didn't see the difference because I used only one tab.