Skip to main content

Topic: sample source code (Read 4606 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • toyoPon3
  • [*]
sample source code
Hi.

I want to program a foobar2000 component which shows the album art.
And, I am searching the site which has the sample source codes of component.
Please tell me the URL of the site shown above.

I prepared the SDK by reading this site.

  • Zao
  • [*][*][*][*][*]
  • Members (Donating)
sample source code
Reply #1
There is a pinned thread named "Pinned: Developer Tutorials" in this forum.
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.

  • toyoPon3
  • [*]
sample source code
Reply #2
To Zao.

Thank you for your reply.
Unfortunately, I could not find the site from the thread that you taught.
(Maybe, my reading skill was not good.)

But  I found the URL shown  in below.
http://foosion.foobar2000.org/components/

thank you.

  • mudlord
  • [*][*][*][*][*]
  • Developer (Donating)
sample source code
Reply #3
Source code for components is also here:
https://github.com/mudlord/foobar2000

  • toyoPon3
  • [*]
sample source code
Reply #4
I wanted to add the  dialog window to foobar2000 by using VC++ 2010 Express. (I can not buy the Professional Edition)
I post my memo for someone who is wondering like me.
------
Outline.
Step1:Add "pref.cpp" to your project.
Step2:Add "resource file" to your project.

pref.cpp and resource file are shown below.
------

I added my tag to "the Preferences pages" by the referring to the topic shown below.
Especially, pref.cpp(Mr.foosion exsample Post#3) was good help for me.
http://www.hydrogenaudio.org/forums/index....mp;#entry373489

And, I made the resource file by using the ResEdit(free tool).
ResEdit:http://www.resedit.net/
I modified two lines for changing from the parent window to the child window.
Note:VC++ Express dose not supply "the res Edit function" to the programer.

My resource file is shown below.

Code: [Select]
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"

// Dialog resources
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG1 DIALOGEX 0, 0, 186, 95
[b]STYLE DS_SETFONT | WS_CHILD      // <- Change
//CAPTION "Dialog"                <- Comment out
[/b]FONT 8, "Ms Shell Dlg", 0, 0, 1
{
   DEFPUSHBUTTON  "OK", IDOK, 129, 7, 50, 14
   PUSHBUTTON      "Cansel", IDCANCEL, 129, 24, 50, 14
   CTEXT          "This is test", IDC_STATIC, 13, 22, 50, 13, SS_CENTER
}
  • Last Edit: 13 August, 2011, 11:33:01 PM by toyoPon3

  • fbuser
  • [*][*][*][*][*]
  • Developer
sample source code
Reply #5
I added my tag to "the Preferences pages" by the referring to the topic shown below.
Especially, pref.cpp(Mr.foosion exsample Post#3) was good help for me.
http://www.hydrogenaudio.org/forums/index....mp;#entry373489
Although this example is still working, it is outdated and the user will get a warning on this. To avoid this preferences_page_3 instead of preferences_page should be implemented.

And, I made the resource file by using the ResEdit(free tool).
ResEdit:http://www.resedit.net/
I modified two lines for changing from the parent window to the child window.
Modifying anything manually is not necessary. Just set the Style to Child in the properties pane for the dialog.
  • Last Edit: 14 August, 2011, 03:37:22 AM by fbuser

  • toyoPon3
  • [*]
sample source code
Reply #6
To Mr.fbuser

Thanks for your reply.

I changed from preferences_page to preferences_page_v3 on your advice.

I read the topic shown below.
http://www.hydrogenaudio.org/forums/index....mp;#entry693611

But I think that this topic is written for VC++ Professional  user.
Is it right?

Then, what should I insert "XXX"?

Code: [Select]
virtual preferences_page_instance::ptr instantiate(HWND parent, preferences_page_callback::ptr callback)
{
 return [b]XXXX[/b];
}
  • Last Edit: 14 August, 2011, 07:57:30 AM by toyoPon3

  • fbuser
  • [*][*][*][*][*]
  • Developer
sample source code
Reply #7
Please, tell me where is wrong.
With only the few code fragments you provided, it is difficult. By I guess with preferences_page_liveshowtagger you implemented preferences_page_v3. You also need to implement preferences_page_instance as shown in the thread you mentioned.

  • toyoPon3
  • [*]
sample source code
Reply #8
To Mr.fbuser

I understood that I need "implement preferences_page_instance".
And I found some sample codes.

But all sample codes are for VC++ Professional user.
* The code needs "CDialogImpl<>".
But I am VC++ Express user.

Then, must I make the function shown below by myself?

1.t_uint32 get_state();
2.void apply();
3.void reset();
4.HWND get_wnd();

Is it right?
Or is there the class for VC++ Express user?

  • toyoPon3
  • [*]
sample source code
Reply #9
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?

------------------------------------

Code: [Select]
#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;

  • fbuser
  • [*][*][*][*][*]
  • Developer
sample source code
Reply #10
You should call my_preferences_page_instance::Create() in the constructor of my_preferences_page_instance and assign the resulting Handle to a class member (e.g. m_wnd). my_preferences_page_instance::get_wnd() must return the handle of your dialog not the parent handle as in your code.

So, your code could look like this
Code: [Select]
#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;
HWND m_wnd;
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){m_wnd=Create(m_parent);}


HWND get_wnd()
{
return m_wnd;
}

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 "Sample Page";
}

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)
{
   return new service_impl_t<my_preferences_page_instance>(parent,callback);
}

};

static preferences_page_factory_t<preferences_sample_page> foo_preferences_sample_page;

  • toyoPon3
  • [*]
sample source code
Reply #11
Mr.fbuser.

Thanks.
My program moves as planned.

I have to study about win32 API.