I posted the full source code of the component (it is very short and simple). Could someone please take a look at it? I am new to both foobar2000 component development and to Microsoft's development tools, so please be gentle.
Is there a way to track down which pure virtual function is being called? I found http://support.microsoft.com/kb/125749 , but couldn't figure out how to set a breakpoint on _purecall(). Opening Debug -> New Breakpoint -> Break at function ... in Visual Studio 2005 Express Edition, and entering "_purecall" does not seem to work.
CODE
#include "../../SDK/foobar2000.h"
DECLARE_COMPONENT_VERSION(
"Remove from Queue",
"0.1",
"Adds a context menu command that removes items from the playback queue.\n"
"Build date: " __DATE__ "\n"
)
class contextmenu : public contextmenu_item_simple {
public:
virtual unsigned get_num_items() { return 1; }
virtual void get_item_name(unsigned p_index, pfc::string_base &p_out) {
if (p_index == 0)
p_out = "Remove from Queue";
}
virtual void get_item_default_path(unsigned int p_index, pfc::string_base &p_out) {
if (p_index == 0)
p_out = "";
}
virtual bool get_item_description(unsigned p_index, pfc::string_base &p_out) {
if (p_index == 0) {
p_out = "Removes one or more items from the playback queue.";
return true;
}
return false;
}
virtual GUID get_item_guid(unsigned p_index) {
static const GUID myguid = {
0x7a30812c, 0xce36, 0x4675,
{ 0xbb, 0xfc, 0x3f, 0x3, 0xb, 0xf7, 0x25, 0x68 }
};
if (p_index == 0)
return myguid;
return pfc::guid_null;
}
virtual void context_command(unsigned p_index, const pfc::list_base_const_t<metadb_handle_ptr> &p_data, const GUID &p_caller) {
if (p_index == 0)
for (t_size i = 0; i < p_data.get_count(); i++)
remove_from_queue(p_data[i]);
}
void remove_from_queue(metadb_handle_ptr &handle);
};
void contextmenu::remove_from_queue(metadb_handle_ptr &handle) {
static static_api_ptr_t<playlist_manager> playlist_api;
if (playlist_api->queue_is_active()) {
pfc::list_t<t_playback_queue_item> queue_contents;
playlist_api->queue_get_contents(queue_contents);
for (int i = int(queue_contents.get_count()-1); i >= 0; i--)
if (queue_contents[i].m_handle == handle) {
playlist_api->queue_remove_mask(bit_array_one(i));
break;
}
}
}
static contextmenu_item_factory_t<contextmenu> foo_contextmenu;
