options_general.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /** (c) Nullsoft, Inc. C O N F I D E N T I A L
  2. ** Filename:
  3. ** Project:
  4. ** Description:
  5. ** Author:
  6. ** Created:
  7. **/
  8. #include "main.h"
  9. #include "resource.h"
  10. #include "options.h"
  11. #include "winampattributes.h"
  12. #include "../nu/ns_wc.h"
  13. static wchar_t icon_tmp[MAX_PATH] = {0};
  14. // setup tab procedure
  15. INT_PTR CALLBACK SetupProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  16. {
  17. hi helpinfo[]={
  18. {IDC_PROXYSTR,IDS_P_SETUP_PROXY},
  19. {IDC_NEWVERCHECK,IDS_P_SETUP_VER},
  20. {IDC_NEWVERCHECK2,IDS_P_SETUP_VER2},
  21. {IDC_COMBO2,IDS_P_SETUP_INTERNET},
  22. {IDC_MINST,IDS_P_SETUP_MINST},
  23. {IDC_PREFS_PRIORITY_CLASS,IDS_P_SETUP_PRIO},
  24. {IDC_SCROLLTITLE,IDS_P_DISP_STITLE},
  25. {IDC_SHOWPLEDITPOS,IDS_P_DISP_SPLEDPOS},
  26. {IDC_SYSTRAY_SCROLLER,IDS_P_DISP_SYSTRAY},
  27. {IDC_CHECK5,IDS_P_DISP_SYSTRAYICON},
  28. {IDC_CHECK1,IDS_P_DISP_TASKBAR},
  29. {IDC_PREFS_SPLASH,IDS_P_O_SPLASH},
  30. {IDC_RECYCLE, IDS_P_O_RECYCLE},
  31. {IDC_NO_MOUSEWHEEL, IDS_P_NO_MOUSEWHEEL},
  32. };
  33. DO_HELP();
  34. switch (uMsg)
  35. {
  36. case WM_INITDIALOG:
  37. {
  38. SendMessageW(GetDlgItem(hwndDlg,IDC_PROXYSTR),EM_LIMITTEXT,sizeof(config_proxy),0);
  39. /// SetWindowTextA(GetDlgItem(hwndDlg,IDC_PROXYSTR),config_proxy); // PROXY disabled
  40. CheckDlgButton(hwndDlg,IDC_MINST,config_minst?1:0);
  41. SendDlgItemMessageW(hwndDlg,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)getStringW(IDS_INST_INET1,NULL,0));
  42. SendDlgItemMessageW(hwndDlg,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)getStringW(IDS_INST_INET2,NULL,0));
  43. SendDlgItemMessageW(hwndDlg,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)getStringW(IDS_INST_INET3,NULL,0));
  44. if (config_inet_mode==3) isInetAvailable(); // autodetect
  45. if (config_inet_mode==2) SendDlgItemMessage(hwndDlg,IDC_COMBO2, CB_SETCURSEL,2,0);
  46. else if (config_inet_mode==1) SendDlgItemMessage(hwndDlg,IDC_COMBO2, CB_SETCURSEL,1,0);
  47. else SendDlgItemMessage(hwndDlg,IDC_COMBO2, CB_SETCURSEL,0,0);
  48. // disable the version and stats aspects as
  49. // they are when internet access is disabled
  50. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK), (config_inet_mode != 2));
  51. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK2), (config_inet_mode != 2));
  52. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK_RC), (config_inet_mode != 2));
  53. if (config_newverchk)
  54. CheckDlgButton(hwndDlg,IDC_NEWVERCHECK,BST_CHECKED);
  55. if (config_newverchk2)
  56. CheckDlgButton(hwndDlg,IDC_NEWVERCHECK2,BST_CHECKED);
  57. if (config_newverchk_rc)
  58. CheckDlgButton(hwndDlg, IDC_NEWVERCHECK_RC, BST_CHECKED);
  59. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK_RC), config_newverchk > 0);
  60. if (GetPrivateProfileIntW(L"Winamp",L"proxyonly80",0,INI_FILE)) CheckDlgButton(hwndDlg,IDC_PROXY_ONLY_PORT_80,BST_CHECKED);
  61. CheckDlgButton(hwndDlg,IDC_DROPAOTFS,config_dropaotfs?1:0);
  62. CheckDlgButton(hwndDlg,IDC_NO_MOUSEWHEEL,config_nomwheel?1:0);
  63. SendDlgItemMessage(hwndDlg,IDC_PREFS_PRIORITY_CLASS,TBM_SETRANGEMAX,0,4);
  64. SendDlgItemMessage(hwndDlg,IDC_PREFS_PRIORITY_CLASS,TBM_SETRANGEMIN,0,0);
  65. SendDlgItemMessage(hwndDlg,IDC_PREFS_PRIORITY_CLASS,TBM_SETPOS,1,4-config_priority);
  66. CheckDlgButton(hwndDlg,IDC_SCROLLTITLE,(config_autoscrollname&2)?1:0);
  67. CheckDlgButton(hwndDlg,IDC_SHOWPLEDITPOS,config_dotasknum);
  68. CheckDlgButton(hwndDlg,IDC_PREFS_SPLASH,config_splash?1:0);
  69. if(!icon_tmp[0]) StringCchPrintfW(icon_tmp,MAX_PATH,L"%s\\winamp.ico",CONFIGDIR);
  70. int custom_icon = PathFileExistsW(icon_tmp);
  71. if(!custom_icon && geticonid(config_sticon) == -666) {
  72. config_sticon = 0;
  73. }
  74. SendDlgItemMessage(hwndDlg,IDC_SYSTRAY_SCROLLER,TBM_SETRANGEMAX,0,12+custom_icon);
  75. SendDlgItemMessage(hwndDlg,IDC_SYSTRAY_SCROLLER,TBM_SETRANGEMIN,0,0);
  76. SendDlgItemMessage(hwndDlg,IDC_SYSTRAY_SCROLLER,TBM_SETPOS,1,config_sticon);
  77. CheckDlgButton(hwndDlg,IDC_RECYCLE,config_playlist_recyclebin?1:0);
  78. CheckDlgButton(hwndDlg, IDC_CHECK1, !(config_taskbar & 1));
  79. EnableWindow(GetDlgItem(hwndDlg, IDC_SCROLLTITLE), !(config_taskbar & 1));
  80. EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWPLEDITPOS), !(config_taskbar & 1));
  81. CheckDlgButton(hwndDlg, IDC_CHECK5, config_taskbar == 1 || config_taskbar == 2);
  82. }
  83. return 0;
  84. case WM_COMMAND:
  85. switch (LOWORD(wParam))
  86. {
  87. case IDC_NEWVERCHECK:
  88. case IDC_NEWVERCHECK2:
  89. config_newverchk=IsDlgButtonChecked(hwndDlg,IDC_NEWVERCHECK)?(config_newverchk?config_newverchk:1):0;
  90. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK_RC), config_newverchk > 0);
  91. if (config_newverchk)
  92. {
  93. config_newverchk_rc = IsDlgButtonChecked(hwndDlg, IDC_NEWVERCHECK_RC) ? (config_newverchk_rc ? config_newverchk_rc : 1) : 0;
  94. }
  95. config_newverchk2=!!IsDlgButtonChecked(hwndDlg,IDC_NEWVERCHECK2);
  96. return 0;
  97. case IDC_COMBO2:
  98. if (HIWORD(wParam) == CBN_SELCHANGE)
  99. {
  100. int l=SendDlgItemMessage(hwndDlg,IDC_COMBO2,CB_GETCURSEL,0,0);
  101. if (l == 2) config_inet_mode=2;
  102. else if (l == 1) config_inet_mode=1;
  103. else config_inet_mode=0;
  104. // disable the version and stats aspects as
  105. // they are when internet access is disabled
  106. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK), (l != 2));
  107. EnableWindow(GetDlgItem(hwndDlg, IDC_NEWVERCHECK2), (l != 2));
  108. }
  109. return 0;
  110. case IDC_MINST:
  111. config_minst = !!IsDlgButtonChecked(hwndDlg,IDC_MINST);
  112. return 0;
  113. case IDC_PROXY_ONLY_PORT_80:
  114. config_proxy80 = (IsDlgButtonChecked(hwndDlg,IDC_PROXY_ONLY_PORT_80)==BST_CHECKED);
  115. WritePrivateProfileStringW(L"Winamp",L"proxyonly80",config_proxy80?L"1":L"0",INI_FILE);
  116. return 0;
  117. case IDC_RECYCLE:
  118. config_playlist_recyclebin = IsDlgButtonChecked(hwndDlg, IDC_RECYCLE)?1:0;
  119. break;
  120. case IDC_PREFS_SPLASH:
  121. config_splash = IsDlgButtonChecked(hwndDlg,IDC_PREFS_SPLASH)?1:0;
  122. break;
  123. case IDC_CHECK1:
  124. case IDC_CHECK5:
  125. if (IsDlgButtonChecked(hwndDlg,IDC_CHECK1)) // taskbar
  126. {
  127. if (IsDlgButtonChecked(hwndDlg,IDC_CHECK5)) config_taskbar=2;
  128. else config_taskbar=0;
  129. }
  130. else // no taskbar
  131. {
  132. if (IsDlgButtonChecked(hwndDlg,IDC_CHECK5)) config_taskbar=1;
  133. else config_taskbar=3;
  134. }
  135. EnableWindow(GetDlgItem(hwndDlg, IDC_SCROLLTITLE), !(config_taskbar & 1));
  136. EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWPLEDITPOS), !(config_taskbar & 1));
  137. if (IsWindow(hMainWindow) && IsWindowVisible(hMainWindow))
  138. {
  139. set_taskbar();
  140. }
  141. else g_taskbar_dirty=1;
  142. break;
  143. case IDC_SCROLLTITLE:
  144. {
  145. int t=config_autoscrollname;
  146. config_autoscrollname &= ~2;
  147. if (IsDlgButtonChecked(hwndDlg,IDC_SCROLLTITLE)) config_autoscrollname |= 2;
  148. {
  149. if (config_autoscrollname && !t) SetTimer(hMainWindow,UPDATE_DISPLAY_TIMER+1,200,NULL);
  150. else if (!config_autoscrollname && t)
  151. {
  152. KillTimer(hMainWindow,UPDATE_DISPLAY_TIMER+1);
  153. }
  154. if (!(config_autoscrollname&2))
  155. set_caption(0, NULL);
  156. }
  157. }
  158. break;
  159. case IDC_SHOWPLEDITPOS:
  160. config_dotasknum = IsDlgButtonChecked(hwndDlg, IDC_SHOWPLEDITPOS)?1:0;
  161. // has cropped up in a few crash reports where app_name is null which causes the update to bork
  162. // when receiving a 'stop' command and we try to send an update via JSAPI1_CurrentTitleChanged()
  163. if (!app_name || app_name && !*app_name || (unsigned int)(ULONG_PTR)app_name < 65536) BuildAppName();
  164. set_caption(0, L"%s - %S", (config_dotasknum?FileTitleNum:FileTitle), app_name);
  165. break;
  166. case IDC_DROPAOTFS:
  167. config_dropaotfs = IsDlgButtonChecked(hwndDlg, IDC_DROPAOTFS)?1:0;
  168. break;
  169. case IDC_NO_MOUSEWHEEL:
  170. config_nomwheel = IsDlgButtonChecked(hwndDlg, IDC_NO_MOUSEWHEEL)?1:0;
  171. break;
  172. } // end of WM_COMMAND
  173. return 0;
  174. case WM_VSCROLL:
  175. {
  176. HWND swnd = (HWND) lParam;
  177. if (swnd == GetDlgItem(hwndDlg,IDC_PREFS_PRIORITY_CLASS))
  178. {
  179. config_priority = 4-(unsigned char)SendMessageW(GetDlgItem(hwndDlg,IDC_PREFS_PRIORITY_CLASS),TBM_GETPOS,0,0);
  180. set_priority();
  181. }
  182. }
  183. return 0;
  184. case WM_DESTROY:
  185. GetWindowTextA(GetDlgItem(hwndDlg,IDC_PROXYSTR),config_proxy,sizeof(config_proxy));
  186. return 0;
  187. case WM_PAINT:
  188. {
  189. PAINTSTRUCT ps;
  190. HICON hIcon;
  191. RECT r;
  192. GetWindowRect(GetDlgItem(hwndDlg,IDC_SYSTRAY_ICON),&r);
  193. ScreenToClient(hwndDlg,(LPPOINT) &r);
  194. ScreenToClient(hwndDlg,(LPPOINT) &r + 1);
  195. BeginPaint(hwndDlg,&ps);
  196. int icon_idx = geticonid(config_sticon);
  197. if(icon_idx != -666) {
  198. hIcon = (HICON)LoadImageW(hMainInstance,MAKEINTRESOURCEW(icon_idx),IMAGE_ICON,16,16,LR_SHARED);
  199. }
  200. else {
  201. if(!PathFileExistsW(icon_tmp)) {
  202. hIcon = (HICON)LoadImageW(hMainInstance,MAKEINTRESOURCEW(ICON_XP),IMAGE_ICON,16,16,LR_SHARED);
  203. }
  204. else {
  205. hIcon = (HICON)LoadImageW(0,icon_tmp,IMAGE_ICON,16,16,LR_LOADFROMFILE);
  206. }
  207. }
  208. if (hIcon)
  209. {
  210. DrawIconEx(ps.hdc,r.left+8,r.top+8,hIcon,16,16,0,NULL,DI_NORMAL);
  211. }
  212. EndPaint(hwndDlg,&ps);
  213. }
  214. break;
  215. case WM_HSCROLL:
  216. {
  217. HWND swnd = (HWND) lParam;
  218. if (swnd == GetDlgItem(hwndDlg,IDC_SYSTRAY_SCROLLER))
  219. {
  220. RECT r;
  221. HWND hwnd;
  222. config_sticon = (unsigned char) SendMessageW(swnd,TBM_GETPOS,0,0);
  223. _w_i("sticon",config_sticon);
  224. hwnd=FindWindowW(L"WinampAgentMain",NULL);
  225. if (hwnd) SendMessageW(hwnd,WM_USER+1,0,0);
  226. GetWindowRect(GetDlgItem(hwndDlg,IDC_SYSTRAY_ICON),&r);
  227. ScreenToClient(hwndDlg,(LPPOINT) &r);
  228. ScreenToClient(hwndDlg,(LPPOINT) &r + 1);
  229. InvalidateRect(hwndDlg,&r,TRUE);
  230. if (hMainWindow && (config_taskbar == 1 || config_taskbar == 2))
  231. {
  232. set_taskbar();
  233. }
  234. }
  235. }
  236. return FALSE;
  237. }
  238. const int controls[] =
  239. {
  240. IDC_PREFS_PRIORITY_CLASS,
  241. IDC_SYSTRAY_SCROLLER,
  242. };
  243. if (FALSE != DirectMouseWheel_ProcessDialogMessage(hwndDlg, uMsg, wParam, lParam, controls, ARRAYSIZE(controls)))
  244. return TRUE;
  245. return 0;
  246. } //setup