QUOTE(mixcherry @ Jun 11 2006, 00:27)

[*]I'm making sort of my own
$set_global(back,<color1>,<color2>) function (used in titleformatting), which I want to use with my
Playlists Dropdown plugin.
Let's say this looks like this (this is pseudo-code, but that's how it works in my component):
CODE
struct style_t
{
HBRUSH background;
HBRUSH background_selected;
};
pfc::list_t< style_t > g_styles;
for (int i=0; i<num_playlists; i++)
{
pfc::string8 null_string;
style_t style;
titleformat_hook_set_style thss = titleformat_hook_set_style(style);
static_api_ptr_t< titleformat_compiler >()->run(&thss, null_string, cfg_style_string);
g_styles.add_item(style);
}
titleformat_hook_set_style is my titleformat_hook class in which I process my
$set_global(...) function (using
cfg_style_string formatting string), nothing special. It just creates two new HBRUSHes (using
CreateSolidBrush()), according to color that user typed in
$set_global(back,...,...) function. Then these brushes are stored in
style variable, which is then added to the global list of all background-styles.
Then, during drawing of each line of my dropdown-list, I can use this list of pre-created
BRUSHes to draw separate backgrounds. This works well, but is terribly slow (during creation of brushes). For example, when you have more than 50 playlists, it takes about 5 seconds to create all brushes...
Is there other way to deal with
$set_global(back,...,...) function, than pre-creating brushes?
[/list]
The obvious speed improvement I see is:
pfc::list_t< style_t , pfc:;alloc_fast_aggressive> g_styles;
g_styles.prealloc(num_playlists);
Alternatively
pfc::list_t< style_t> g_styles;
g_styles.set_count(num_playlists);
Even more alternatively, use pfc::array_t.
Anyone of those would give a small speed improvement. But not 5 seconds! You could equally use pfc::string8_fast_agressive for the null_string, but nothing should be written to it so it doesn't matter.
I would be surprised if CreateSolidBrush is the source of the rest of the slowdown. To render one screen of the Columns UI playlist, it can create maybe 200 brushes and there isn't any slowdown from that. Is it a Debug build? Otherwise you should profile each section using say the profiler macro to find the cause of the slowdown.
QUOTE(gfngfgf @ Jun 12 2006, 06:38)

QUOTE(mixcherry @ Jun 10 2006, 16:27)

- How do you make Tab Control to look like this (e.g. on Columns UI's Preferences Page):
(...)
I mean, how do you get this pretty, gradiented background? I guess it's somehow connected with XP Styles...
Your post made me take a look at foo_uie_albumart, which exhibits the same problem. The answer is pretty simple: Make a call to EnableThemeDialogTexture() (check the Platform SDK for documentation) for each tab just after they are created. The only issue might be compatibility with Windows 2000. I don't have a copy to test with...
Yes that is what I do. Windows 2000 doesn't come with uxtheme.dll, so you need to load the library using either the LoadLibrary method or the delay-load method.