I implemented my_preferences_page_instance(sub class of preferences_page_instance).
And I finish compiling.
It shows the tags "Sample Page".
But it dose not show the dialog.
I insert the debug line "console::info("Call ConfigProc");" in ConfigProc().
"Console window" shows "Call ConfigProc" only several times.
After that, "Console window" does not show any line.
Where is wrong?
------------------------------------
#include "resource.h"
#include "../SDK/foobar2000.h"
#include "../helpers/helpers.h"
static const GUID guid_prefs_tagging = { 0x563107c3, 0xfc7d, 0x4022, { 0xa8, 0x72, 0xa8, 0x2a, 0x2b, 0x3f, 0xd5, 0x25 } };
static preferences_branch_factory foo_preferences_branch_tagging(guid_prefs_tagging, preferences_page::guid_tools, "Tagging");
const char strText[] = "sample test";
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
{
console::info("Call ConfigProc");
switch (msg)
{
case WM_INITDIALOG:
{
uSetDlgItemText(wnd, IDC_EDIT1, strText);
}
break;
case WM_COMMAND:
break;
default:
return FALSE;
}
return TRUE;
}
class my_preferences_page_instance : public preferences_page_instance
{
protected:
t_uint32 m_state;
HWND m_parent;
preferences_page_callback::ptr m_callback;
public:
my_preferences_page_instance(HWND parent, preferences_page_callback::ptr callback) :
m_callback(callback),
m_parent(parent),
m_state(preferences_state::resettable){}
HWND get_wnd()
{
return m_parent;
}
t_uint32 get_state()
{
return m_state;
}
// Applies preferences changes.
void apply()
{
console::info("Call apply");
m_state = preferences_state::resettable;
m_callback->on_state_changed();
}
// Resets this page's content to the default values.
// Does not apply any changes -
// lets user preview the changes before hitting "apply".
void reset()
{
m_state |= preferences_state::changed;
// m_callback->on_state_changed();
}
HWND Create(HWND parent)
{
console::info("Call create");
return uCreateDialog(IDD_DIALOG1, parent, ConfigProc, 0);
}
};
static const GUID guid_prefs_sample = { 0x13be3cd2, 0xbff3, 0x42cc, { 0x96, 0xda, 0x7f, 0xfc, 0x7a, 0x4a, 0x3d, 0x6 } };
class preferences_sample_page : public preferences_page_v3
{
public:
virtual const char * get_name()
{
return [b]"Sample Page";[/b]
}
virtual GUID get_guid()
{
return guid_prefs_sample;
}
virtual GUID get_parent_guid()
{
return guid_prefs_tagging;
}
virtual preferences_page_instance::ptr instantiate(HWND parent, preferences_page_callback::ptr callback)
{
service_impl_t<my_preferences_page_instance> * p = new service_impl_t<my_preferences_page_instance>(parent,callback);
p->Create(parent);
return p;
}
};
static preferences_page_factory_t<preferences_sample_page> foo_preferences_sample_page;