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: Redraw window on playback (Read 2067 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Redraw window on playback

I want to redraw a panel/window when i start playback of a track (on_playback_new_track), but i have a problem to access wnd of the window


As the basis for my code, i use foo_uie_example:

Code: [Select]
/** Our window class */
class color_window : public uie::container_ui_extension
{
public:
color_window();
~color_window();

virtual const GUID & get_extension_guid() const;
virtual void get_name(pfc::string_base & out)const;
virtual void get_category(pfc::string_base & out)const;
unsigned get_type () const;

private:
/** Our window procedure */
LRESULT on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp);

virtual class_data & get_class_data()const;
virtual void get_menu_items (uie::menu_hook_t & p_hook);

static const GUID g_extension_guid;

/** Our child window */
HWND wnd_static;
};

........

LRESULT color_window::on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
{

switch(msg)
{
case WM_CREATE:
{
GetClientRect(wnd, &rc);
/** Create a static window*/
wnd_static = CreateWindowEx(0, WC_STATIC, _T("color"),
WS_CHILD | WS_VISIBLE, 0, 0, rc.right, rc.bottom,
wnd, HMENU(0), core_api::get_my_instance(), NULL);
}
break;

.....


class play_callback_color : public play_callback_static
{

public:
virtual unsigned get_flags(void)
{
return(flag_on_playback_new_track);
}
virtual void on_playback_new_track( metadb_handle_ptr p_track )
{
//How can i redraw child window wnd_static from here
//ShowWindow(wnd_static, SW_SHOW); UpdateWindow(wnd_static); RedrawWindow(wnd_static, 0, 0, RDW_INTERNALPAINT); ????
//No access to private!!! member wnd_static of class color_window whatever i do.
}
................

Can you give a hint?

 

Redraw window on playback

Reply #1
You've got several possible solutions here, but you need to bear in mind that there might be more than one instance of your UI panel.

You can either have your callback finding and accessing all instances of the panel or having each instance register itself with a global collection which the callback can access.

If you go with the first way, you can get hold of the window handle either through member functions, friendship or making the variable public.
If you go with the second way, you'd have a service or just a plain global set (PFC probably has something, otherwise, std::set), in which you in your panels register any windows you create on creation, and remove them when they're destroyed.

Another suggestion from IRC is that you can just simply inherit your panel class from play_callback_impl_base, which would automagically register a play_callback for each instance of your panel.

The last way would be the simplest, but if you want to decouple it somewhat, the second way works too.
Stay sane, exile.