sample source code |
This forum is for developer discussions only. If you have a problem / bug report / idea / feature request that isn't related to foobar2000 SDK, post it in an appropiate forum instead - tech support questions go to support forum, everything else goes to general forum.
All non-developer posts on this forum will be removed. Continued abuse of this forum will result in admin actions (warnings, account suspension).
![]() ![]() |
sample source code |
Jul 23 2011, 09:52
Post
#1
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
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. |
|
|
|
Jul 23 2011, 14:46
Post
#2
|
|
![]() Group: Members (Donating) Posts: 766 Joined: 25-September 03 From: Umeå, Sweden Member No.: 9001 |
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. |
|
|
|
Jul 25 2011, 15:36
Post
#3
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
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. |
|
|
|
Jul 25 2011, 16:01
Post
#4
|
|
![]() Group: Developer (Donating) Posts: 711 Joined: 1-December 07 Member No.: 49165 |
Source code for components is also here:
https://github.com/mudlord/foobar2000 |
|
|
|
Aug 14 2011, 04:32
Post
#5
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
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 #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 STYLE DS_SETFONT | WS_CHILD // <- Change //CAPTION "Dialog" <- Comment out 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 } This post has been edited by toyoPon3: Aug 14 2011, 04:33 |
|
|
|
Aug 14 2011, 08:17
Post
#6
|
|
|
Group: Developer Posts: 647 Joined: 26-September 07 Member No.: 47369 |
I added my tag to "the Preferences pages" by the referring to the topic shown below. 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.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). Modifying anything manually is not necessary. Just set the Style to Child in the properties pane for the dialog.
ResEdit:http://www.resedit.net/ I modified two lines for changing from the parent window to the child window. This post has been edited by fbuser: Aug 14 2011, 08:37 |
|
|
|
Aug 14 2011, 12:03
Post
#7
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
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 virtual preferences_page_instance::ptr instantiate(HWND parent, preferences_page_callback::ptr callback)
{ return XXXX; } This post has been edited by toyoPon3: Aug 14 2011, 12:57 |
|
|
|
Aug 14 2011, 12:46
Post
#8
|
|
|
Group: Developer Posts: 647 Joined: 26-September 07 Member No.: 47369 |
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. |
|
|
|
Aug 14 2011, 13:41
Post
#9
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
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? |
|
|
|
Aug 15 2011, 08:32
Post
#10
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
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 #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 "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) { 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; |
|
|
|
Aug 15 2011, 09:01
Post
#11
|
|
|
Group: Developer Posts: 647 Joined: 26-September 07 Member No.: 47369 |
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 #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; |
|
|
|
Aug 15 2011, 13:43
Post
#12
|
|
|
Group: Members Posts: 10 Joined: 23-July 11 Member No.: 92480 |
Mr.fbuser.
Thanks. My program moves as planned. I have to study about win32 API. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 21st May 2013 - 23:01 |