Skip to main content
Topic: how to add simplest configuration dialog (Read 3988 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

how to add simplest configuration dialog

How to add simplest configuration dialog to my plugin? Please, provide some sample code. Thanx!

how to add simplest configuration dialog

Reply #1
Your best bet for example code would be to 1) find the source of a component and mimic it, or 2) find the 0.8.3 SDK and look at the examples (the HTTP reader is a good simple one). The configuration pages have pretty much kept the same API from 8 to 9.

Not sure why all the great examples are ripped out of the 0.9 SDK..

Edit: Thought I'd be more helpful.. (this is for 0.8 you'll have to change some stuff for 0.9. From what I can tell the changes are pretty minor)
Code: [Select]
class config_http : public config
{
static BOOL CALLBACK DialogProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
{
switch(msg)
{
case WM_INITDIALOG:
uSetDlgItemInt(wnd,IDC_BUFSIZE,cfg_buffer_size/1024,0);
uSendDlgItemMessage(wnd,IDC_PREBUF_START,TBM_SETRANGE,0,MAKELONG(1,100));
uSendDlgItemMessage(wnd,IDC_PREBUF_UNDERRUN,TBM_SETRANGE,0,MAKELONG(1,100));
uSendDlgItemMessage(wnd,IDC_PREBUF_START,TBM_SETPOS,1,cfg_prebuffer_start);
uSendDlgItemMessage(wnd,IDC_PREBUF_UNDERRUN,TBM_SETPOS,1,cfg_prebuffer_underrun);
uSetDlgItemText(wnd,IDC_STATUS_PREBUF1,string_printf("%u%%",(int)cfg_prebuffer_start));
uSetDlgItemText(wnd,IDC_STATUS_PREBUF2,string_printf("%u%%",(int)cfg_prebuffer_underrun));
uSendDlgItemMessageText(wnd,IDC_PROXY_MODE,CB_ADDSTRING,0,"Don't use proxy");
uSendDlgItemMessageText(wnd,IDC_PROXY_MODE,CB_ADDSTRING,0,"Use proxy only for port 80 connections");
uSendDlgItemMessageText(wnd,IDC_PROXY_MODE,CB_ADDSTRING,0,"Use proxy for all connections");
uSendDlgItemMessage(wnd,IDC_PROXY_MODE,CB_SETCURSEL,cfg_proxy_mode,0);
g_proxy_sync.enter();
uSetDlgItemText(wnd,IDC_PROXY_URL,cfg_proxy_url);
g_proxy_sync.leave();
uSendDlgItemMessage(wnd,IDC_ICY_METADATA,BM_SETCHECK,cfg_icy_metadata,0);
break;
case WM_COMMAND:
switch(wp)
{
case (CBN_SELCHANGE<<16) | IDC_PROXY_MODE:
cfg_proxy_mode = uSendMessage((HWND)lp,CB_GETCURSEL,0,0);
break;
case (EN_CHANGE<<16)|IDC_BUFSIZE:
cfg_buffer_size = uGetDlgItemInt(wnd,IDC_BUFSIZE,0,0) * 1024;
break;
case (EN_CHANGE<<16)|IDC_PROXY_URL:
g_proxy_sync.enter();
cfg_proxy_url = string_utf8_from_window((HWND)lp);
g_proxy_sync.leave();
break;
case IDC_ICY_METADATA:
cfg_icy_metadata = uSendMessage((HWND)lp,BM_GETCHECK,0,0);
break;
}
break;
case WM_HSCROLL:
switch(uGetWindowLong((HWND)lp,GWL_ID))
{
case IDC_PREBUF_START:
cfg_prebuffer_start = uSendMessage((HWND)lp,TBM_GETPOS,0,0);
uSetDlgItemText(wnd,IDC_STATUS_PREBUF1,string_printf("%u%%",(int)cfg_prebuffer_start));
break;
case IDC_PREBUF_UNDERRUN:
cfg_prebuffer_underrun = uSendMessage((HWND)lp,TBM_GETPOS,0,0);
uSetDlgItemText(wnd,IDC_STATUS_PREBUF2,string_printf("%u%%",(int)cfg_prebuffer_underrun));
break;
}
break;
}
return 0;
}
virtual HWND create(HWND parent)
{
return uCreateDialog(IDD_CONFIG,parent,DialogProc);
}
virtual const char * get_name() {return "HTTP Reader";}
virtual const char * get_parent_name() {return "Components";}
};

static service_factory_single_t<config,config_http> foo2;

how to add simplest configuration dialog

Reply #2
Here is an example for a preferences page implementation for 0.9 (taken from foo_tradersfriend): prefs.cpp.

Noteworthy points are:
  • Preferences pages are now identified by GUID instead of by name, so you will have to add get_guid() and change get_parent_name() to get_parent_guid(). The GUIDs for some standard pages are available as static members of the preferences_page class.
  • 0.9 allows to reset settings for individual pages. To support that you have to return true from reset_query() and implement reset(); the framework will destroy you preferences page window before calling reset() and recreate it afterwards.
  • You can add your own branches to the preferences tree for use as a parent to multiple pages which might be in different components. To do that, create a preferences_branch_factory. The branch introduced by this will display as a an empty page if selected and will only display, if it has children. You can have multiple declarations for a single preferences branch (usually in different components); the framework will merge branches with the same GUID and display (at most) one instance.

how to add simplest configuration dialog

Reply #3
Is there any possibility to edit Dialog Boxes in VC++ Express?? There was special "drag & drop" editor in good old VC++ 6.0 where I could easily place my controls (List Boxes, Buttons, Edits, etc.) on my form, and now I have to manually (in normal text editor) edit my .rc files (for example with my config dialog box) - which is not very exciting

When I try to open my old .rc (from 0.8 project) in VC++ Express, it just says "Resource Editing is not supported on the Visual C++ Express SKU". Do you know any external tool that would allow me to easily edit my dialog boxes with GUI?

how to add simplest configuration dialog

Reply #4
No, there isn't. That's one of the restrictions of the free version. I don't know any other dialog resource editors that are not part of some commercial IDE, but perhaps Google does.

how to add simplest configuration dialog

Reply #5
Thanks for help, and I want to know which is the "components" 's GUID? I guess is "guid_tools"?

 

 
SimplePortal 1.0.0 RC1 © 2008-2019