uiBurnPlayList.cpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. #include "./uiBurnPlaylist.h"
  2. #include "./resource.h"
  3. #include <shlwapi.h>
  4. #include <commctrl.h>
  5. #include <strsafe.h>
  6. #include "./uiCheckMedium.h"
  7. #include "./uiUnitReady.h"
  8. #define WM_PLBURNERCOMMAND ((WM_USER) + 26)
  9. #define PLB_LICENSE 0
  10. #define PLB_DECODE 1
  11. #define PLB_BURN 2
  12. #define TIMER_UPDATECLOCK_ID 1979
  13. #define TIMER_UPDATECLOCK_INTERVAL 1000
  14. #define TIMER_PROGRESS_ID 1978
  15. #define TIMER_PROGRESS_INTERVAL 500
  16. #define COLUMN_COUNT 0
  17. #define COLUMN_TITLE 1
  18. #define COLUMN_DURATION 2
  19. #define COLUMN_STATUS 3
  20. #define COLUMN_FILENAME 4
  21. const int COLUMNWIDTH[] = {20, 220, 60, 102, 280};
  22. const int COLUMNALLIGN[] = {LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_CENTER, LVCFMT_LEFT, LVCFMT_LEFT};
  23. const int COLUMNNAME[] = {IDS_COLUMN_INDEX, IDS_COLUMN_TITLE, IDS_COLUMN_DURATION, IDS_COLUMN_STATUS, IDS_COLUMN_FILE};
  24. const COLORREF strip[] = { RGB(198, 238, 255), RGB(184, 233, 255), RGB(167, 227, 255), RGB(151, 221, 255), RGB(133, 215, 255), RGB(115, 208, 255), RGB(99, 202, 255),
  25. RGB(82, 196, 255), RGB(64, 190, 255), RGB(46, 184, 255), RGB(29, 177, 255), RGB(12, 171, 255), RGB(2, 165, 255), RGB(0, 158, 255) };
  26. static UINT uMsgBroadcastNotify = 0;
  27. BurnPlaylistUI::BurnPlaylistUI(void)
  28. {
  29. hwnd = NULL;
  30. tmpfilename = NULL;
  31. hTmpFile = NULL;
  32. currentPercent = -1;
  33. stripBmp = NULL;
  34. cancelOp = FALSE;
  35. workDone = NULL;
  36. readyClose = TRUE;
  37. ZeroMemory(&estimated, sizeof(aproxtime));
  38. }
  39. BurnPlaylistUI::~BurnPlaylistUI(void)
  40. {
  41. if(hwnd) DestroyWindow(hwnd);
  42. if (hTmpFile)
  43. {
  44. CloseHandle(hTmpFile);
  45. hTmpFile=0;
  46. }
  47. if (tmpfilename)
  48. {
  49. DeleteFileW(tmpfilename);
  50. free(tmpfilename);
  51. tmpfilename=0;
  52. }
  53. }
  54. DWORD BurnPlaylistUI::Burn(obj_primo *primoSDK, DWORD drive, DWORD maxspeed, DWORD burnFlags, BurnerPlaylist *playlist,
  55. const wchar_t* tempPath, HWND ownerWnd)
  56. {
  57. if (!primoSDK) return BURNPLAYLISTUI_PRIMOSDKNOTSET;
  58. DWORD retCode;
  59. extendedView = FALSE;
  60. this->primoSDK = primoSDK;
  61. this->drive = drive;
  62. this->playlist = playlist;
  63. this->maxspeed = maxspeed;
  64. this->burnFlags = burnFlags;
  65. this->ownerWnd = ownerWnd;
  66. stage = PLSTAGE_READY;
  67. wchar_t fname[64] = {0};
  68. DWORD uid = GetTickCount() & 0x00FFFFFF;
  69. StringCchPrintfW(fname, 64, L"wa%06I32X.tmp", uid);
  70. tmpfilename = (wchar_t*)malloc((lstrlenW(tempPath) + 48)*sizeof(wchar_t));
  71. if (tempPath) PathCombineW(tmpfilename, tempPath, fname);
  72. else
  73. {
  74. wchar_t path[2048] = {0};
  75. GetTempPathW(2048, path);
  76. PathCombineW(tmpfilename, path, fname);
  77. }
  78. LPCDLGTEMPLATE templ = NULL;
  79. HRSRC hres = FindResourceExW(hResource, MAKEINTRESOURCEW(5), MAKEINTRESOURCEW(IDD_DLG_BURNER), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
  80. if (hres) templ = (LPCDLGTEMPLATE)LoadResource(hResource, hres);
  81. retCode = (DWORD)DialogBoxIndirectParamW(dllInstance, templ, NULL, (DLGPROC)WndProc, (LPARAM)this);
  82. return retCode;
  83. }
  84. void BurnPlaylistUI::OnInitDialog(HWND hwndDlg)
  85. {
  86. hwnd = hwndDlg;
  87. errCode = BURNPLAYLISTUI_SUCCESS;
  88. SetPropW(hwnd, L"WABURNER", hwnd);
  89. SetPropW(hwnd, L"DRIVE", (HANDLE)(INT_PTR)drive);
  90. EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ADDTODB), (PRIMOSDK_TEST != (burnFlags&PRIMOSDK_TEST)));
  91. CheckDlgButton(hwndDlg, IDC_CHK_ADDTODB, BST_CHECKED);
  92. CheckDlgButton(hwndDlg, IDC_CHK_EJECT, BST_CHECKED);
  93. if (ownerWnd) PostMessage(ownerWnd, WM_BURNNOTIFY, BURN_READY, (LPARAM)hwnd);
  94. if (!uMsgBroadcastNotify) uMsgBroadcastNotify = RegisterWindowMessageA("WABURNER_BROADCAST_MSG");
  95. if (uMsgBroadcastNotify) SendNotifyMessage(HWND_BROADCAST, uMsgBroadcastNotify, (WPARAM)(0xFF & drive), (LPARAM)TRUE);
  96. SetExtendedView(extendedView);
  97. SetColumns();
  98. FillList();
  99. wchar_t format[512] = {0}, buffer[512] = {0};
  100. SetReadyClose(TRUE);
  101. LoadStringW(hResource, IDS_BURNINGCDDA, format, 512);
  102. StringCchPrintfW(buffer, 512, format, drive);
  103. if (PRIMOSDK_TEST == (burnFlags&PRIMOSDK_TEST))
  104. {
  105. HANDLE hImage = NULL;
  106. hImage = LoadBitmapW(hResource, MAKEINTRESOURCEW(IDB_TESTMODE));
  107. if(hImage == NULL){
  108. hImage = LoadBitmapW(dllInstance, MAKEINTRESOURCEW(IDB_TESTMODE));
  109. }
  110. SendDlgItemMessage(hwnd, IDC_PIC_TESTMODE, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hImage);
  111. ShowWindow(GetDlgItem(hwnd, IDC_PIC_TESTMODE), SW_SHOW);
  112. }
  113. SetDlgItemTextW(hwnd, IDC_LBL_CAPTION, buffer);
  114. SendDlgItemMessage(hwnd, IDC_PRG_TOTAL, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
  115. SetProgress(0);
  116. startedTime = GetTickCount();
  117. /// estimation
  118. realSpeed = 0;
  119. DWORD retCode, reqspeed;
  120. WAMEDIUMINFO detectedMedium;
  121. retCode = GetMediumInfo(primoSDK, &drive, &detectedMedium); // required before GetDiscSpeed
  122. if (PRIMOSDK_OK == retCode)
  123. {
  124. switch(maxspeed)
  125. {
  126. case PRIMOSDK_MAX:
  127. reqspeed = 0xFFFFFFFF;
  128. break;
  129. case PRIMOSDK_BEST:
  130. reqspeed = 0xFFFFFFF0;
  131. break;
  132. case PRIMOSDK_MIN:
  133. reqspeed = 0x00000000;
  134. break;
  135. case PRIMOSDK_MEDIUM:
  136. reqspeed = 0x0000FFFF;
  137. break;
  138. default: reqspeed = maxspeed*100;
  139. }
  140. // TODO: benski> should "retCode =" go before this?
  141. primoSDK->GetDiscSpeed(&drive, reqspeed, &realSpeed);
  142. if (PRIMOSDK_OK != retCode) realSpeed = 0;
  143. }
  144. if (!realSpeed) realSpeed = 4*100;
  145. estimated.license = (DWORD)playlist->GetCount();
  146. estimated.convert = playlist->GetTotalLengthMS() /(60*1000);
  147. estimated.transition = 0;
  148. estimated.chkdisc = 1;
  149. estimated.init = 1;
  150. estimated.leadin = 20;
  151. estimated.burn = playlist->GetTotalLengthMS()/(realSpeed*10);
  152. estimated.leadout = 20;
  153. estimated.finish = 5;
  154. estimatedTime = 0;
  155. UpdateTime(TRUE);
  156. ShowWindow(hwnd, SW_SHOWNORMAL);
  157. SetForegroundWindow(hwnd);
  158. BringWindowToTop(hwnd);
  159. UpdateWindow(hwnd);
  160. SetTimer(hwnd, TIMER_UPDATECLOCK_ID, TIMER_UPDATECLOCK_INTERVAL, NULL);
  161. hTmpFile = CreateFileW(tmpfilename, GENERIC_READ|GENERIC_WRITE/*FILE_APPEND_DATA | FILE_READ_DATA*/, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_HIDDEN, NULL);
  162. if (INVALID_HANDLE_VALUE == hTmpFile)
  163. {
  164. wchar_t title[64] = {0};
  165. hTmpFile = NULL;
  166. LoadStringW(hResource, IDS_TEMPORARY_FILE, title, 64);
  167. MessageBoxW(NULL, tmpfilename, title, MB_OK);
  168. ReportError(IDS_TMPCREATEFAILED, FALSE);
  169. return;
  170. }
  171. PostMessage(hwnd, WM_PLBURNERCOMMAND, PLB_LICENSE, 0);
  172. return;
  173. }
  174. void BurnPlaylistUI::SetColumns(void)
  175. {
  176. HWND ctrlWnd = GetDlgItem(hwnd, IDC_LST_DETAILS);
  177. LVCOLUMNW clmn = {0};
  178. clmn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT;
  179. int count = sizeof(COLUMNWIDTH) /sizeof(int);
  180. wchar_t buffer[512] = {0};
  181. for (int i = 0; i < count; i++)
  182. {
  183. LoadStringW(hResource, COLUMNNAME[i], buffer, 512);
  184. clmn.cx = COLUMNWIDTH[i];
  185. clmn.fmt = COLUMNALLIGN[i];
  186. clmn.pszText = buffer;
  187. clmn.iSubItem = i;
  188. SendMessageW(ctrlWnd, LVM_INSERTCOLUMNW, i, (LPARAM)&clmn);
  189. }
  190. // extra styles
  191. SendMessageW(ctrlWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,
  192. /*LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES |*/ LVS_EX_LABELTIP,
  193. /*LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES |*/ LVS_EX_LABELTIP);
  194. }
  195. void BurnPlaylistUI::FillList(void)
  196. {
  197. HWND ctrlWnd = GetDlgItem(hwnd, IDC_LST_DETAILS);
  198. LVITEMW item = {0};
  199. wchar_t buffer[128] = {0};
  200. for(size_t i = 0; i < playlist->GetCount(); i++)
  201. {
  202. BurnerItem *bi = playlist->at(i);
  203. item.mask = LVIF_TEXT | LVIF_PARAM;
  204. item.iItem = (int)i;
  205. item.iSubItem = COLUMN_COUNT;
  206. _i64tow_s(i + 1, buffer, 128, 10);
  207. item.pszText = buffer;
  208. item.lParam = (LPARAM)bi;
  209. SendMessage(ctrlWnd, LVM_INSERTITEMW, 0, (LPARAM)&item);
  210. item.mask = LVIF_TEXT;
  211. item.iSubItem = COLUMN_TITLE;
  212. item.pszText = const_cast<wchar_t*>(bi->GetTitle());
  213. SendMessage(ctrlWnd, LVM_SETITEMW, 0, (LPARAM)&item);
  214. item.iSubItem = COLUMN_DURATION;
  215. item.pszText = GetTimeString(buffer, 128, bi->GetLength()/1000);
  216. SendMessage(ctrlWnd, LVM_SETITEMW, 0, (LPARAM)&item);
  217. item.iSubItem = COLUMN_STATUS;
  218. item.pszText = L"";
  219. SendMessage(ctrlWnd, LVM_SETITEMW, 0, (LPARAM)&item);
  220. item.iSubItem = COLUMN_FILENAME;
  221. item.pszText = const_cast<wchar_t*>(bi->GetFullName());
  222. SendMessage(ctrlWnd, LVM_SETITEMW, 0, (LPARAM)&item);
  223. }
  224. }
  225. void BurnPlaylistUI::SetProgress(int position)
  226. {
  227. if (currentPercent == position) return;
  228. wchar_t buffer[8] = {0};
  229. StringCchPrintfW(buffer, 8, L"%d%%", position);
  230. SetDlgItemTextW(hwnd, IDC_LBL_PERCENT, buffer);
  231. SendDlgItemMessage(hwnd, IDC_PRG_TOTAL, PBM_SETPOS, position, 0);
  232. currentPercent = position;
  233. }
  234. void BurnPlaylistUI::UpdateTime(BOOL recalcEstimates)
  235. {
  236. wchar_t buffer[128] = {0};
  237. if (recalcEstimates)
  238. {
  239. estimatedTime = 0;
  240. DWORD *pe = (DWORD*)&estimated;
  241. for (int i = 0; i < sizeof(estimated) /sizeof(DWORD); i++) estimatedTime += pe[i];
  242. SetWindowTextW(GetDlgItem(hwnd, IDC_LBL_ESTIMATED_VAL), GetTimeString(buffer, 128, estimatedTime));
  243. }
  244. unsigned int elapsedTime = (GetTickCount() - startedTime)/1000;
  245. SetWindowTextW(GetDlgItem(hwnd, IDC_LBL_ELAPSED_VAL), GetTimeString(buffer, 128, elapsedTime));
  246. if (estimatedTime <= elapsedTime)
  247. {
  248. estimatedTime = elapsedTime;
  249. SetWindowTextW(GetDlgItem(hwnd, IDC_LBL_ESTIMATED_VAL), buffer);
  250. }
  251. }
  252. void BurnPlaylistUI::ReportError(unsigned int stringCode, BOOL allowContinue)
  253. {
  254. wchar_t buffer[512] = {0};
  255. LoadStringW(hResource, stringCode, buffer, 512);
  256. ReportError(buffer, allowContinue);
  257. }
  258. void BurnPlaylistUI::ReportError(const wchar_t *errorString, BOOL allowContinue)
  259. {
  260. HWND ctrlWnd;
  261. if (!allowContinue)
  262. {
  263. // stop timer and set progress to the end
  264. estimatedTime = 0;
  265. KillTimer(hwnd, TIMER_UPDATECLOCK_ID);
  266. SetProgress(100);
  267. // update time
  268. UpdateTime(FALSE);
  269. }
  270. else
  271. {
  272. ShowWindow(GetDlgItem(hwnd, IDC_BTN_CONTINUE), SW_SHOW);
  273. }
  274. // set caption to the Burning canceled.
  275. wchar_t buffer[128] = {0}, format[128] = {0};
  276. LoadStringW(hResource, (allowContinue) ? IDS_BURNINGSTOPPED : IDS_BURNINGCANCELED, format, 128);
  277. StringCchPrintfW(buffer, 128, format, drive);
  278. SetDlgItemTextW(hwnd, IDC_LBL_CAPTION, buffer);
  279. LoadStringW(hResource, IDS_REASON, buffer, 128);
  280. // set operation info to Cancelation cause: error message
  281. SetDlgItemTextW(hwnd, IDC_LBL_CURRENTOPERATION, buffer);
  282. SetDlgItemTextW(hwnd, IDC_LBL_CURRENTOPERATION_VAL, errorString);
  283. // set cancel/close button to 'close' mode and enable it
  284. LoadStringW(hResource, IDS_CLOSE, buffer, 128);
  285. ctrlWnd = GetDlgItem(hwnd, IDCANCEL);
  286. SetWindowTextW(ctrlWnd, buffer);
  287. EnableWindow(ctrlWnd, TRUE);
  288. // set extended view (show all info)
  289. SetExtendedView(TRUE);
  290. // make some noise
  291. MessageBeep(MB_ICONHAND);
  292. // set status to ready for closing
  293. SetReadyClose(TRUE);
  294. // if somebody waiting - we done!
  295. if(workDone) SetEvent(workDone);
  296. if (!allowContinue) if (uMsgBroadcastNotify) SendNotifyMessage(HWND_BROADCAST, uMsgBroadcastNotify, (WPARAM)(0xFF & drive), (LPARAM)FALSE);
  297. }
  298. void BurnPlaylistUI::UpdateItemStatus(int index)
  299. {
  300. LVITEMW lvi;
  301. lvi.mask = LVIF_TEXT;
  302. lvi.iItem = index;
  303. lvi.iSubItem= COLUMN_STATUS;
  304. lvi.pszText = NULL;
  305. SendDlgItemMessage(hwnd, IDC_LST_DETAILS, LVM_SETITEMW, 0, (LPARAM)&lvi);
  306. }
  307. void BurnPlaylistUI::SetItemStatusText(int index, unsigned int stringCode, BOOL redraw)
  308. {
  309. wchar_t buffer[128] = {0};
  310. LoadStringW(hResource, stringCode, buffer, 128);
  311. LVITEMW lvi = {0};
  312. lvi.mask = LVIF_TEXT;
  313. lvi.iItem = index;
  314. lvi.iSubItem = COLUMN_STATUS;
  315. lvi.pszText = buffer;
  316. HWND lstWnd = GetDlgItem(hwnd, IDC_LST_DETAILS);
  317. SendMessage(lstWnd, LVM_SETITEMW, 0, (LPARAM)&lvi);
  318. if (redraw) ListView_RedrawItems(lstWnd, index, index);
  319. }
  320. void BurnPlaylistUI::SetCurrentOperation(unsigned int stringCode)
  321. {
  322. wchar_t buffer[128] = {0};
  323. LoadStringW(hResource, stringCode, buffer, 128);
  324. SetDlgItemTextW(hwnd, IDC_LBL_CURRENTOPERATION_VAL, buffer);
  325. }
  326. int BurnPlaylistUI::MessageBox(unsigned int messageCode, unsigned int captionCode, unsigned int uType)
  327. {
  328. wchar_t message[512] = {0}, caption[64] = {0};
  329. LoadStringW(hResource, messageCode, message, 512);
  330. LoadStringW(hResource, captionCode, caption, 64);
  331. return MessageBoxW(hwnd, message, caption, uType);
  332. }
  333. void BurnPlaylistUI::OnCancel(void)
  334. {
  335. ShowWindow(GetDlgItem(hwnd, IDC_BTN_CONTINUE), SW_HIDE);
  336. if (!readyClose && workDone)
  337. {
  338. HWND btnWnd = GetDlgItem(hwnd, IDCANCEL);
  339. EnableWindow(btnWnd, FALSE);
  340. wchar_t message[512] = {0}, caption[64] = {0};
  341. LoadStringW(hResource, IDS_MB_CANCELBURNING, message, 512);
  342. LoadStringW(hResource, IDS_CONFIRMATION, caption, 64);
  343. if (IDYES != MessageBoxW(hwnd, message, caption, MB_YESNO | MB_ICONQUESTION | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST))
  344. {
  345. EnableWindow(btnWnd, TRUE);
  346. return;
  347. }
  348. wchar_t buffer[64] = {0};
  349. LoadStringW(hResource, IDS_BURNINGABORTEDBYUSER, buffer, 64);
  350. SetDlgItemTextW(hwnd, IDC_LBL_CAPTION, buffer);
  351. SetCurrentOperation(IDS_CANCELING);
  352. cancelOp = TRUE;
  353. MSG msg;
  354. SetTimer(hwnd, TIMER_PROGRESS_ID, TIMER_PROGRESS_INTERVAL, NULL);
  355. while (WAIT_TIMEOUT == WaitForSingleObject(workDone, 20))
  356. {
  357. while (PeekMessageW(&msg, NULL, 0,0, PM_REMOVE))
  358. {
  359. if(IsDialogMessage(hwnd, &msg)) continue;
  360. TranslateMessage(&msg);
  361. DispatchMessageW(&msg);
  362. }
  363. }
  364. KillTimer(hwnd, TIMER_PROGRESS_ID);
  365. cancelOp = FALSE;
  366. CloseHandle(workDone);
  367. workDone = NULL;
  368. KillTimer(hwnd, TIMER_UPDATECLOCK_ID);
  369. SetProgress(100);
  370. estimatedTime = 0;
  371. UpdateTime(FALSE);
  372. if (hTmpFile)
  373. {
  374. CloseHandle(hTmpFile);
  375. hTmpFile = NULL;
  376. }
  377. if (tmpfilename) DeleteFileW(tmpfilename);
  378. SetReadyClose(TRUE);
  379. EnableWindow(btnWnd, TRUE);
  380. MessageBeep(MB_OK);
  381. DWORD errorCode;
  382. DWORD status = playlist->GetStatus(&errorCode);
  383. if (ownerWnd) PostMessage(ownerWnd, WM_BURNNOTIFY, BURN_FINISHED, errorCode);
  384. if (uMsgBroadcastNotify)
  385. {
  386. SendNotifyMessage(HWND_BROADCAST, uMsgBroadcastNotify, (WPARAM)(0xFF & drive), (LPARAM)FALSE);
  387. }
  388. if(BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_CHK_AUTOCLOSE) || BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_CHK_HIDEWINDOW))
  389. {
  390. PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), (LPARAM)GetDlgItem(hwnd, IDCANCEL));
  391. }
  392. }
  393. else
  394. {
  395. if (workDone) CloseHandle(workDone);
  396. workDone = NULL;
  397. if (tmpfilename) DeleteFileW(tmpfilename);
  398. PostMessage(hwnd, WM_DESTROY, 0,0);
  399. }
  400. }
  401. void BurnPlaylistUI::SetReadyClose(BOOL ready)
  402. {
  403. readyClose = ready;
  404. wchar_t buffer[32] = {0};
  405. LoadStringW(hResource, (readyClose) ? IDS_CLOSE : IDS_CANCEL, buffer, 32);
  406. SetDlgItemTextW(hwnd, IDCANCEL, buffer);
  407. }
  408. void BurnPlaylistUI::OnDestroy(void)
  409. {
  410. if (stripBmp)
  411. {
  412. DeleteObject(stripBmp);
  413. stripBmp = NULL;
  414. }
  415. if (hTmpFile)
  416. {
  417. CloseHandle(hTmpFile);
  418. hTmpFile = NULL;
  419. }
  420. if (tmpfilename)
  421. {
  422. DeleteFileW(tmpfilename);
  423. free(tmpfilename);
  424. tmpfilename = NULL;
  425. }
  426. EndDialog(hwnd, errCode);
  427. if (ownerWnd) PostMessage(ownerWnd, WM_BURNNOTIFY, BURN_DESTROYED, 0);
  428. }
  429. void BurnPlaylistUI::SetExtendedView(BOOL extView)
  430. {
  431. extendedView = extView;
  432. if (!hwnd) return;
  433. ShowWindow(GetDlgItem(hwnd, IDC_LST_DETAILS), extView);
  434. ShowWindow(GetDlgItem(hwnd, IDC_GRP_OPTIONS), extView);
  435. ShowWindow(GetDlgItem(hwnd, IDC_CHK_AUTOCLOSE), extView);
  436. ShowWindow(GetDlgItem(hwnd, IDC_CHK_EJECT), extView);
  437. ShowWindow(GetDlgItem(hwnd, IDC_CHK_ADDTODB), extView);
  438. ShowWindow(GetDlgItem(hwnd, IDC_CHK_HIDEWINDOW), extView);
  439. RECT rw;
  440. HWND ctrlWnd;
  441. GetWindowRect(hwnd, &rw);
  442. int height = (extView) ? 413 : 147;
  443. SetWindowPos(hwnd, HWND_TOP, 0, 0, rw.right - rw.left, height, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
  444. ctrlWnd = GetDlgItem(hwnd, IDC_BTN_EXTENDEDVIEW);
  445. wchar_t buffer[32] = {0};
  446. LoadStringW(hResource, (extView) ? IDS_SHOWLESS : IDS_SHOWMORE, buffer, 32);
  447. SetWindowTextW(ctrlWnd, buffer);
  448. }
  449. HBITMAP BurnPlaylistUI::CreateStripBmp(HDC compDC)
  450. {
  451. HDC hdc = CreateCompatibleDC(compDC);
  452. if (!hdc) return NULL;
  453. BITMAPINFO info;
  454. // create DIB Section
  455. info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  456. info.bmiHeader.biWidth = 1;
  457. info.bmiHeader.biHeight = -14;
  458. info.bmiHeader.biPlanes = 1;
  459. info.bmiHeader.biBitCount = 24;
  460. info.bmiHeader.biCompression = BI_RGB;
  461. info.bmiHeader.biSizeImage = 0;
  462. info.bmiHeader.biXPelsPerMeter = 0;
  463. info.bmiHeader.biYPelsPerMeter = 0;
  464. info.bmiHeader.biClrUsed = 0;
  465. info.bmiHeader.biClrImportant = 0;
  466. void *data;
  467. HBITMAP bmp = CreateDIBSection(hdc, (const BITMAPINFO*) &info, DIB_RGB_COLORS, &data, NULL, 0);
  468. if (bmp)
  469. {
  470. CopyMemory(data, strip, sizeof(strip));
  471. }
  472. DeleteDC(hdc);
  473. return bmp;
  474. }
  475. DWORD BurnPlaylistUI::DrawList(NMLVCUSTOMDRAW* listDraw)
  476. {
  477. switch(listDraw->nmcd.dwDrawStage)
  478. {
  479. case CDDS_PREPAINT:
  480. return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT;
  481. case CDDS_ITEMPREPAINT:
  482. if ((int)listDraw->nmcd.dwItemSpec%2)
  483. {
  484. listDraw->clrTextBk = RGB(238, 238, 238);//GetSysColor(COLOR_WINDOW);
  485. }
  486. {
  487. BurnerItem *bi = (BurnerItem*)listDraw->nmcd.lItemlParam;
  488. DWORD biCode;
  489. int status = bi->GetStatus(&biCode);
  490. switch(status)
  491. {
  492. case BURNERITEM_LICENSING:
  493. case BURNERITEM_DECODING:
  494. case BURNERITEM_BURNING:
  495. listDraw->clrText = RGB(30, 120, 40);
  496. break;
  497. case BURNERITEM_LICENSED:
  498. case BURNERITEM_DECODED:
  499. case BURNERITEM_BURNED:
  500. switch(biCode)
  501. {
  502. case BURNERITEM_SUCCESS:
  503. listDraw->clrText = RGB(10, 10, 60);
  504. break;
  505. case BURNERITEM_ABORTED:
  506. listDraw->clrText = RGB(100, 10, 40);
  507. break;
  508. default:
  509. listDraw->clrText = RGB(220, 0, 0);
  510. break;
  511. }
  512. break;
  513. case BURNERITEM_ABORTED:
  514. listDraw->clrText = RGB(96, 24, 24);
  515. break;
  516. case BURNERITEM_SKIPPED:
  517. listDraw->clrText = RGB(204, 204, 220);
  518. break;
  519. }
  520. }
  521. return CDRF_DODEFAULT | CDRF_NOTIFYSUBITEMDRAW;
  522. case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
  523. {
  524. BurnerItem *bi = (BurnerItem*)listDraw->nmcd.lItemlParam;
  525. DWORD biCode;
  526. int status = bi->GetStatus(&biCode);
  527. switch(status)
  528. {
  529. case BURNERITEM_DECODING:
  530. case BURNERITEM_BURNING:
  531. if (listDraw->iSubItem == COLUMN_STATUS)
  532. {
  533. if (!stripBmp) stripBmp = CreateStripBmp(listDraw->nmcd.hdc);
  534. HDC hdc = CreateCompatibleDC(listDraw->nmcd.hdc);
  535. HGDIOBJ tmpBmp = SelectObject(hdc, stripBmp);
  536. RECT rc;
  537. ListView_GetSubItemRect(listDraw->nmcd.hdr.hwndFrom, (int)listDraw->nmcd.dwItemSpec, COLUMN_STATUS, LVIR_BOUNDS, &rc);
  538. HBRUSH hb = ((int)listDraw->nmcd.dwItemSpec%2) ? CreateSolidBrush(RGB(240, 242, 245)) :GetSysColorBrush(COLOR_WINDOW);
  539. RECT rb;
  540. SetRect(&rb, rc.left, rc.top, rc.left + 4, rc.bottom);
  541. FillRect(listDraw->nmcd.hdc, &rb, hb);
  542. SetRect(&rb, rc.left + 4, rc.top, rc.right - 4, rc.top + 1);
  543. FillRect(listDraw->nmcd.hdc, &rb, hb);
  544. SetRect(&rb, rc.left + 4, rc.bottom - 1, rc.right - 4, rc.bottom);
  545. FillRect(listDraw->nmcd.hdc, &rb, hb);
  546. int len = int (((float)(rc.right - rc.left - 8)) * (((float)biCode)/100.0f));
  547. SetRect(&rb, rc.left + 4 + len, rc.top, rc.right, rc.bottom);
  548. FillRect(listDraw->nmcd.hdc, &rb, hb);
  549. for (int i = rc.left + 4; i < rc.left + 4 + len; i++)
  550. {
  551. BitBlt(listDraw->nmcd.hdc, i, rc.top + 1, 1, rc.bottom - rc.top -2, hdc, 0, 0, SRCCOPY);
  552. }
  553. SelectObject(hdc, tmpBmp);
  554. DeleteDC(hdc);
  555. wchar_t buffer[32] = {0}, text[64] = {0};
  556. LoadStringW(hResource, (BURNERITEM_DECODING == status) ? IDS_PREPARING : IDS_BURNING, buffer, 32);
  557. StringCchPrintfW(text, 64, L"%s (%d%%)" , buffer, biCode);
  558. SetTextColor(listDraw->nmcd.hdc, RGB(30, 120, 0));
  559. SetBkMode(listDraw->nmcd.hdc,TRANSPARENT);
  560. InflateRect(&rc, -4, 0);
  561. DrawTextW(listDraw->nmcd.hdc, text, -1, &rc, DT_CENTER | DT_VCENTER |DT_END_ELLIPSIS |DT_SINGLELINE);
  562. if((int)listDraw->nmcd.dwItemSpec%2) DeleteObject(hb);
  563. return CDRF_SKIPDEFAULT;
  564. }
  565. break;
  566. }
  567. }
  568. break;
  569. default:
  570. break;
  571. }
  572. return CDRF_DODEFAULT;
  573. }
  574. void BurnPlaylistUI::OnLicense(void)
  575. {
  576. SetReadyClose(FALSE);
  577. if (workDone) ResetEvent(workDone);
  578. if (ownerWnd) PostMessage(ownerWnd, WM_BURNNOTIFY, BURN_WORKING, 0);
  579. controlTime = GetTickCount();
  580. if (!workDone) workDone = CreateEvent(NULL, FALSE, FALSE, NULL);
  581. playlist->CheckLicense(OnLicensingPlaylist, this);
  582. }
  583. void BurnPlaylistUI::OnDecode(void)
  584. {
  585. prevRefresh = 0;
  586. SetReadyClose(FALSE);
  587. if (workDone) ResetEvent(workDone);
  588. if (ownerWnd) PostMessage(ownerWnd, WM_BURNNOTIFY, BURN_WORKING, 0);
  589. controlTime = GetTickCount();
  590. ShowWindow(GetDlgItem(hwnd, IDC_BTN_CONTINUE), SW_HIDE);
  591. DWORD retCode = playlist->Decode(hTmpFile, OnDecodePlaylist, this, FALSE);
  592. if (BURNERPLAYLIST_DECODESTARTING == retCode)
  593. {
  594. if(!workDone) workDone = CreateEvent(NULL, FALSE, FALSE, NULL);
  595. }
  596. }
  597. void BurnPlaylistUI::OnBurn(void)
  598. {
  599. // check disc
  600. SetReadyClose(FALSE);
  601. if (workDone) ResetEvent(workDone);
  602. if (ownerWnd) PostMessage(ownerWnd, WM_BURNNOTIFY, BURN_WORKING, 0);
  603. estimated.transition = (GetTickCount() - controlTime)/1000;
  604. UpdateTime(TRUE);
  605. ShowWindow(GetDlgItem(hwnd, IDC_BTN_CONTINUE), SW_HIDE);
  606. DWORD totalSectors = playlist->GetTotalSectors();
  607. SetReadyClose(FALSE);
  608. controlTime = GetTickCount();
  609. WAMEDIUMINFO mi;
  610. FillMemory(&mi, sizeof(WAMEDIUMINFO), 0xFF);
  611. mi.recordable = TRUE;
  612. mi.isCD = TRUE;
  613. mi.freeSectors = totalSectors; // plus lead-in
  614. CheckMediumUI cm;
  615. SetProgress(0);
  616. SetCurrentOperation(IDS_CHECKINGDISC);
  617. DWORD time =totalSectors/75;
  618. int min = time / 60 + ((time % 60) ? 1 : 0);
  619. wchar_t string[512] = {0};
  620. LoadStringW(hResource, IDS_BURNREQDISC, string, 512);
  621. wchar_t buffer[512] = {0};
  622. StringCchPrintfW(buffer, 512, string, min);
  623. DWORD retCode = cm.Check(primoSDK, &drive, &mi, buffer, FALSE, TRUE, hwnd);
  624. estimated.chkdisc = (GetTickCount() - controlTime)/1000;
  625. UpdateTime(TRUE);
  626. switch(retCode)
  627. {
  628. case CHECKMEDIUMUI_MATCH:
  629. {
  630. // start burning
  631. DWORD reqspeed;
  632. unsigned int strcode;
  633. switch(maxspeed)
  634. {
  635. case PRIMOSDK_MAX:
  636. reqspeed = 0xFFFFFFFF;
  637. strcode = IDS_SPEEDMAX;
  638. break;
  639. case PRIMOSDK_BEST:
  640. reqspeed = 0xFFFFFFF0;
  641. strcode = IDS_SPEEDBEST;
  642. break;
  643. case PRIMOSDK_MIN:
  644. reqspeed = 0x00000000;
  645. strcode = IDS_SPEEDMIN;
  646. break;
  647. case PRIMOSDK_MEDIUM:
  648. reqspeed = 0xFFFFF000;
  649. strcode = IDS_SPEEDMED;
  650. break;
  651. default:
  652. reqspeed = maxspeed*100;
  653. strcode = IDS_SPEED;
  654. break;
  655. }
  656. primoSDK->GetDiscSpeed(&drive, reqspeed, &realSpeed);
  657. wchar_t at[8] = {0}, spd[16] = {0}, spddesc[32] = {0};
  658. StringCchPrintfW(spd, 16, L"%d.%02dx", realSpeed/100, realSpeed%100);
  659. LoadStringW(hResource, strcode, spddesc, 32);
  660. LoadStringW(hResource, IDS_BURNINGCDDA, buffer, 512);
  661. StringCchPrintfW(string, 512, buffer, drive);
  662. LoadStringW(hResource, IDS_AT, at, 8);
  663. switch(maxspeed)
  664. {
  665. case PRIMOSDK_BEST:
  666. StringCchPrintfW(buffer, 512, L"%s %s %s", string, at, spddesc);
  667. break;
  668. case PRIMOSDK_MAX:
  669. case PRIMOSDK_MEDIUM:
  670. case PRIMOSDK_MIN:
  671. StringCchPrintfW(buffer,512, L"%s %s %s (%s)", string, at, spddesc, spd);
  672. break;
  673. default:
  674. StringCchPrintfW(buffer,512, L"%s %s %s %s", string, at, spd, spddesc);
  675. break;
  676. }
  677. SetDlgItemTextW(hwnd, IDC_LBL_CAPTION, buffer);
  678. retCode = playlist->Burn(primoSDK, drive, maxspeed, burnFlags, hTmpFile,OnBurnPlaylist, this, FALSE);
  679. if (BURNERPLAYLIST_BURNSTARTING == retCode)
  680. {
  681. if (!workDone) workDone = CreateEvent(NULL, FALSE, FALSE, NULL);
  682. SetReadyClose(FALSE);
  683. return;
  684. }
  685. break;
  686. }
  687. case CHECKMEDIUMUI_CANCELED: ReportError(IDS_BURNINGABORTEDBYUSER, FALSE); break;
  688. case CHECKMEDIUMUI_DISCNOTSET: ReportError(IDS_CHKDSCWRONGPARAMETER, FALSE); break;
  689. case CHECKMEDIUMUI_DRIVENOTSET: ReportError(IDS_CHKDSCWRONGPARAMETER, FALSE); break;
  690. case CHECKMEDIUMUI_PRIMOSDKNOTSET: ReportError(IDS_CHKDSCWRONGPARAMETER, FALSE); break;
  691. case CHECKMEDIUMUI_UNABLETOCREATEDIALOG: ReportError(IDS_CHKDSCDIALOGFAILED, FALSE); break;
  692. case CHECKMEDIUMUI_MESSAGEPUMPERROR: ReportError(IDS_CHKDSCMSGPUMPFAILED, FALSE); break;
  693. default:
  694. {
  695. ReportError(IDS_PRIMOINITFAILED, FALSE);
  696. DWORD statCode, cmd, sense, asc, ascq;
  697. statCode = primoSDK->UnitStatus(&drive, &cmd, &sense, &asc, &ascq);
  698. wchar_t caption[64] = {0}, message[512] = {0}, myerror[128] = {0}, libprfx[32] = {0}, liberror[128] = {0}, drvprfx[32] = {0}, drverror[128] = {0};
  699. LoadStringW(hResource, IDS_BURNERROR, caption, 64);
  700. LoadStringW(hResource, IDS_PRIMOINITFAILED, myerror, 128);
  701. LoadStringW(hResource, IDS_LIBERRORPREFIX, libprfx, 32);
  702. LoadStringW(hResource, IDS_DRVERRORPREFIX, drvprfx, 32);
  703. GetPrimoCodeText(liberror, 128, statCode);
  704. GetUnitStatusText(drverror, 128, sense, asc, ascq);
  705. StringCchPrintfW(message, 512, L"%s%s%s%s%s", myerror, libprfx, liberror, drvprfx, drverror);
  706. MessageBoxW(hwnd, message, caption, MB_OK | MB_ICONEXCLAMATION);
  707. }
  708. break;
  709. }
  710. SetReadyClose(TRUE);
  711. if (workDone) SetEvent(workDone);
  712. }
  713. DWORD BurnPlaylistUI::OnLicensingPlaylist(void *sender, void *userparam, DWORD notifyCode, DWORD errorCode, ULONG_PTR param)
  714. {
  715. BurnPlaylistUI *dlg = (BurnPlaylistUI *) userparam;
  716. switch (notifyCode)
  717. {
  718. case BURNERPLAYLIST_LICENSINGFINISHED:
  719. dlg->stage = PLSTAGE_LICENSED;
  720. dlg->estimated.license = (GetTickCount() - dlg->controlTime)/1000;
  721. dlg->UpdateTime(TRUE);
  722. KillTimer(dlg->hwnd, TIMER_PROGRESS_ID);
  723. dlg->SetProgress(100);
  724. switch(errorCode)
  725. {
  726. case BURNERPLAYLIST_FILENOTLICENSED: // param contains number of successfully processed files
  727. dlg->ReportError(IDS_LICENSEFAILED, (param) ? TRUE : FALSE);
  728. if(param)
  729. {
  730. dlg->estimated.convert = ((int)param)/(60*1000);
  731. dlg->estimated.burn = ((int)param)/(dlg->realSpeed*10);
  732. dlg->controlTime = GetTickCount();
  733. dlg->MessageBox(IDS_LICENSEFAILEDMSG, IDS_BURNERROR, MB_OK | MB_ICONERROR);
  734. dlg->estimated.transition += (GetTickCount() - dlg->controlTime)/1000;
  735. dlg->UpdateTime(TRUE);
  736. }
  737. break;
  738. case BURNERPLAYLIST_SUCCESS: dlg->SetCurrentOperation(IDS_LICENSESUCCESS); break;
  739. case BURNERPLAYLIST_NOFILES: dlg->ReportError(IDS_NOFILES, FALSE); break;
  740. case BURNERPLAYLIST_DECODESERVICEFAILED: dlg->ReportError(IDS_DECODESERVICEFAILED, FALSE); break;
  741. case BURNERPLAYLIST_WRONGFILECOUNT: dlg->ReportError(IDS_LICENSEWRONGFILECOUNT, FALSE); break;
  742. default: dlg->ReportError(IDS_LICENSEFAILED, FALSE); break;
  743. }
  744. PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, 0);
  745. if (BURNERPLAYLIST_SUCCESS == errorCode) PostMessage(dlg->hwnd, WM_PLBURNERCOMMAND, PLB_DECODE, 0);
  746. break;
  747. case BURNERPLAYLIST_LICENSINGSTARTING:
  748. switch(errorCode)
  749. {
  750. case BURNERPLAYLIST_ITEMADDED: dlg->SetItemStatusText((int)param, IDS_LICENSEITEMPROGRESS, TRUE); break;
  751. case BURNERPLAYLIST_ADDITEMSKIPPED: dlg->SetItemStatusText((int)param, IDS_SKIPPED, TRUE); break;
  752. case BURNERPLAYLIST_SUCCESS:
  753. dlg->SetCurrentOperation(IDS_LICENSEPROGRESS);
  754. SetTimer(dlg->hwnd, TIMER_PROGRESS_ID, 100, NULL);
  755. break;
  756. }
  757. break;
  758. case BURNERPLAYLIST_LICENSINGPROGRESS:
  759. unsigned int strcode(IDS_UNKNOWN);
  760. switch(errorCode)
  761. {
  762. case BURN_OK: dlg->SetItemStatusText((int)param, IDS_LICENSEITEMSUCCESS, TRUE); break;
  763. case BURN_FILE_NOT_FOUND: dlg->SetItemStatusText((int)param, IDS_FILENOTFOUND, TRUE); break;
  764. case BURN_DRM_NO_LICENSE: dlg->SetItemStatusText((int)param, IDS_DRMNOLICENSE, TRUE); break;
  765. case BURN_DRM_NOT_ALLOWED: dlg->SetItemStatusText((int)param, IDS_DRMNOBURNING, TRUE); break;
  766. case BURN_DRM_BURN_COUNT_EXCEEDED: dlg->SetItemStatusText((int)param, IDS_DRMBURNCOUNTEXCEEDED, TRUE); break;
  767. case BURN_NO_DECODER: dlg->SetItemStatusText((int)param, IDS_NODECODER, TRUE); break;
  768. default: dlg->SetItemStatusText((int)param, IDS_LICENSEITEMFAILED, TRUE); break;
  769. }
  770. break;
  771. }
  772. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  773. return (!dlg->cancelOp) ? BURNERPLAYLIST_CONTINUE : BURNERPLAYLIST_STOP;
  774. }
  775. DWORD BurnPlaylistUI::OnDecodePlaylist(void *sender, void *userparam, DWORD notifyCode, DWORD errorCode, ULONG_PTR param)
  776. {
  777. BurnPlaylistUI *dlg = (BurnPlaylistUI *) userparam;
  778. switch (notifyCode)
  779. {
  780. case BURNERPLAYLIST_DECODESTARTING:
  781. switch(errorCode)
  782. {
  783. case BURNERPLAYLIST_SUCCESS:
  784. dlg->SetCurrentOperation(IDS_PREPARINGDATA);
  785. dlg->processed = 0;
  786. dlg->count = 0;
  787. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  788. break;
  789. case BURNERPLAYLIST_ITEMADDED: dlg->SetItemStatusText((int)param, IDS_SCHEDULED, TRUE); dlg->count++; break;
  790. case BURNERPLAYLIST_ADDITEMSKIPPED: dlg->SetItemStatusText((int)param, IDS_SKIPPED, TRUE); break;
  791. }
  792. break;
  793. case BURNERPLAYLIST_DECODEFINISHED:
  794. dlg->stage = PLSTAGE_DECODED;
  795. dlg->SetProgress(100);
  796. dlg->estimated.convert = (GetTickCount() - dlg->controlTime)/1000;
  797. dlg->UpdateTime(TRUE);
  798. dlg->controlTime = GetTickCount();
  799. dlg->estimated.burn = dlg->playlist->GetStateLengthMS(BURNERITEM_DECODED, BURNERITEM_SUCCESS)/(dlg->realSpeed*10);
  800. switch(errorCode)
  801. {
  802. case BURNERPLAYLIST_SUCCESS:
  803. dlg->SetCurrentOperation(IDS_PREPARESUCCESS);
  804. PostMessage(dlg->hwnd, WM_PLBURNERCOMMAND, PLB_BURN, 0);
  805. break;
  806. case BURNERPLAYLIST_NOFILES: dlg->ReportError(IDS_NOFILES, FALSE); break;
  807. case BURNERPLAYLIST_ABORTED: dlg->ReportError(IDS_BURNINGABORTEDBYUSER, FALSE); break;
  808. case BURNERPLAYLIST_DECODESERVICEFAILED: dlg->ReportError(IDS_DECODESERVICEFAILED, FALSE); break;
  809. case BURNERPLAYLIST_THREADCREATEFAILED: dlg->ReportError(IDS_DECODESTARTFAILED, FALSE); break;
  810. default:
  811. dlg->ReportError(IDS_PREPAREFAILED, TRUE);
  812. dlg->MessageBox(IDS_PREPAREFAILEDMSG, IDS_BURNERROR, MB_OK | MB_ICONERROR);
  813. dlg->estimated.transition += (GetTickCount() - dlg->controlTime)/1000;
  814. dlg->UpdateTime(TRUE);
  815. break;
  816. }
  817. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  818. break;
  819. case BURNERPLAYLIST_DECODEPROGRESS:
  820. {
  821. BPLDECODEINFO *info = (BPLDECODEINFO*)param;
  822. switch(errorCode)
  823. {
  824. case BURNERPLAYLIST_DECODENEXTITEM:
  825. if(!dlg->cancelOp)
  826. {
  827. wchar_t text[64] = {0}, of[16] = {0}, buffer[128] = {0};
  828. BPLDECODEINFO *info = (BPLDECODEINFO*)param;
  829. LoadStringW(hResource, IDS_PREPARINGDATA, text, 64);
  830. LoadStringW(hResource, IDS_OF, of, 16);
  831. StringCchPrintfW(buffer, 128, L"%s ( %d %s %d )", text, dlg->processed + 1, of, dlg->count);
  832. SetDlgItemTextW(dlg->hwnd, IDC_LBL_CURRENTOPERATION_VAL, buffer);
  833. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, info->iIndex);
  834. }
  835. break;
  836. case BURNERPLAYLIST_DECODEITEM:
  837. switch(info->iNotifyCode)
  838. {
  839. case BURNERITEM_DECODESTARTING:
  840. ListView_RedrawItems(GetDlgItem(dlg->hwnd, IDC_LST_DETAILS), info->iIndex, info->iIndex);
  841. if(!dlg->cancelOp) dlg->SetProgress((int)info->percentCompleted);
  842. break;
  843. case BURNERITEM_DECODEPROGRESS:
  844. if (GetTickCount() - dlg->prevRefresh < 100) break;
  845. dlg->UpdateItemStatus(info->iIndex);
  846. if(!dlg->cancelOp)
  847. {
  848. dlg->SetProgress((int)info->percentCompleted);
  849. if ((int)info->percentCompleted)
  850. {
  851. dlg->estimated.convert = (GetTickCount() - dlg->controlTime)/((int)(info->percentCompleted*10));
  852. dlg->UpdateTime(TRUE);
  853. }
  854. }
  855. dlg->prevRefresh = GetTickCount();
  856. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMDECODEPROGRESS, info->iIndex);
  857. break;
  858. case BURNERITEM_DECODEFINISHED:
  859. switch(info->iErrorCode)
  860. {
  861. case BURNERITEM_SUCCESS: dlg->SetItemStatusText(info->iIndex, IDS_PREPAREITEMSUCCESS, TRUE); break;
  862. case BURNERITEM_ABORTED: dlg->SetItemStatusText(info->iIndex, IDS_CANCELED, TRUE); break;
  863. case BURNERITEM_BADFILENAME: dlg->SetItemStatusText(info->iIndex, IDS_BADFILENAME, TRUE); break;
  864. case BURNERITEM_UNABLEOPENFILE: dlg->SetItemStatusText(info->iIndex, IDS_NODECODER, TRUE); break;
  865. case BURNERITEM_WRITEERROR: dlg->SetItemStatusText(info->iIndex, IDS_CACHEWRITEFAILED, TRUE); break;
  866. default:
  867. dlg->SetItemStatusText(info->iIndex, IDS_PREPAREITEMFAILED, TRUE);
  868. dlg->estimated.burn -= info->iInstance->GetLength()/(dlg->realSpeed*10);
  869. dlg->UpdateTime(TRUE);
  870. break;
  871. }
  872. dlg->processed++;
  873. if(!dlg->cancelOp) dlg->SetProgress((int)info->percentCompleted);
  874. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, info->iIndex);
  875. break;
  876. }
  877. break;
  878. }
  879. }
  880. break;
  881. case BURNERPLAYLIST_DECODECANCELING: dlg->SetCurrentOperation(IDS_CANCELING); break;
  882. }
  883. return (!dlg->cancelOp) ? BURNERPLAYLIST_CONTINUE : BURNERPLAYLIST_STOP;
  884. }
  885. DWORD BurnPlaylistUI::OnBurnPlaylist(void *sender, void *userparam, DWORD notifyCode, DWORD errorCode, ULONG_PTR param)
  886. {
  887. BurnPlaylistUI *dlg = (BurnPlaylistUI *) userparam;
  888. BurnerPlaylist *playlist = (BurnerPlaylist*)sender;
  889. switch (notifyCode)
  890. {
  891. case BURNERPLAYLIST_BURNSTARTING:
  892. switch(errorCode)
  893. {
  894. case BURNERPLAYLIST_SUCCESS: dlg->SetCurrentOperation(IDS_MASTERINGDISC); break;
  895. case BURNERPLAYLIST_ITEMADDED:
  896. dlg->SetItemStatusText((int)param, IDS_SCHEDULED, TRUE);
  897. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, param);
  898. break;
  899. case BURNERPLAYLIST_ADDITEMSKIPPED:
  900. dlg->SetItemStatusText((int)param, IDS_SKIPPED, TRUE);
  901. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, param);
  902. break;
  903. case BURNERPLAYLIST_ADDITEMFAILED:
  904. dlg->SetItemStatusText((int)param, IDS_BURNITEMADDFAILED, TRUE);
  905. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, param);
  906. break;
  907. case BURNERPLAYLIST_BEGINBURN: dlg->SetCurrentOperation(IDS_INITIALIZINGBURNER); break;
  908. }
  909. break;
  910. case BURNERPLAYLIST_BURNPROGRESS:
  911. switch(errorCode)
  912. {
  913. case BURNERPLAYLIST_WRITELEADIN:
  914. dlg->estimated.init = (GetTickCount() - dlg->controlTime)/1000;
  915. dlg->controlTime = GetTickCount();
  916. dlg->UpdateTime(TRUE);
  917. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  918. if (dlg->cancelOp) break;
  919. dlg->SetCurrentOperation(IDS_WRITELEADIN);
  920. break;
  921. case BURNERPLAYLIST_WRITELEADOUT:
  922. dlg->controlTime = GetTickCount();
  923. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  924. if (dlg->cancelOp) break;
  925. dlg->SetCurrentOperation(IDS_WRITELEADOUT);
  926. break;
  927. case BURNERPLAYLIST_DISCOPEN:
  928. if (!dlg->cancelOp) dlg->SetCurrentOperation(IDS_DISCOPEN);
  929. break;
  930. case BURNERPLAYLIST_DISCCLOSE:
  931. if (!dlg->cancelOp) dlg->SetCurrentOperation(IDS_DISCCLOSE);
  932. break;
  933. case BURNERPLAYLIST_WRITEITEMBEGIN:
  934. if (((BPLRUNSTATUS*)param)->iIndex == 0)
  935. {
  936. dlg->estimated.leadin = (GetTickCount() - dlg->controlTime)/1000;
  937. dlg->controlTime = GetTickCount();
  938. }
  939. ListView_RedrawItems(GetDlgItem(dlg->hwnd, IDC_LST_DETAILS), ((BPLRUNSTATUS*)param)->iIndex, ((BPLRUNSTATUS*)param)->iIndex);
  940. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, ((BPLRUNSTATUS*)param)->iIndex);
  941. break;
  942. case BURNERPLAYLIST_WRITEITEMEND:
  943. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMSTATECHANGED, ((BPLRUNSTATUS*)param)->iIndex);
  944. if (dlg->cancelOp) break;
  945. dlg->SetItemStatusText(((BPLRUNSTATUS*)param)->iIndex, IDS_BURNITEMSUCCESS, TRUE);
  946. break;
  947. case BURNERPLAYLIST_WRITEDATA:
  948. {
  949. BPLRUNSTATUS *status = (BPLRUNSTATUS*)param;
  950. int percent = (int)(status->sCurrent * 100 / status->sTotal);
  951. if (!percent) break;
  952. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_ITEMBURNPROGRESS, ((BPLRUNSTATUS*)param)->iIndex);
  953. if (dlg->cancelOp) break;
  954. if (dlg->currentPercent != percent)
  955. {
  956. dlg->SetProgress(percent);
  957. wchar_t format[128] = {0}, buffer[164] = {0};
  958. LoadStringW(hResource, IDS_BURNPROGRESS, format, 128);
  959. StringCchPrintfW(buffer, 164, format , percent);
  960. SetDlgItemTextW(dlg->hwnd, IDC_LBL_CURRENTOPERATION_VAL, buffer);
  961. }
  962. dlg->UpdateItemStatus(((BPLRUNSTATUS*)param)->iIndex);
  963. dlg->estimated.burn = (GetTickCount() - dlg->controlTime)/((int)(percent*10));
  964. dlg->UpdateTime(TRUE);
  965. }
  966. break;
  967. }
  968. break;
  969. case BURNERPLAYLIST_BURNFINISHING:
  970. dlg->estimated.leadout = (GetTickCount() - dlg->controlTime)/1000;
  971. dlg->UpdateTime(TRUE);
  972. dlg->controlTime = GetTickCount();
  973. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  974. playlist->SetEjectWhenDone((BST_CHECKED == IsDlgButtonChecked(dlg->hwnd, IDC_CHK_EJECT)) ? PRIMOSDK_OPENTRAYEJECT : 0);
  975. if (dlg->cancelOp) break;
  976. dlg->SetCurrentOperation(IDS_RELEASINGBURNER);
  977. break;
  978. case BURNERPLAYLIST_BURNFINISHED:
  979. dlg->stage = PLSTAGE_BURNED;
  980. dlg->estimated.finish = (GetTickCount() - dlg->controlTime)/1000;
  981. dlg->SetProgress(100);
  982. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_FINISHED, errorCode);
  983. switch(errorCode)
  984. {
  985. case BURNERPLAYLIST_ABORTED: dlg->ReportError(IDS_BURNINGABORTEDBYUSER, FALSE); return BURNERPLAYLIST_STOP;
  986. case BURNERPLAYLIST_NOFILES: dlg->ReportError(IDS_NOFILES, FALSE); return BURNERPLAYLIST_STOP;
  987. case BURNERPLAYLIST_ADDITEMFAILED: dlg->ReportError(IDS_MASTERINGFAILED, FALSE); return BURNERPLAYLIST_STOP;
  988. case BURNERPLAYLIST_THREADCREATEFAILED: dlg->ReportError(IDS_BURNSTARTFAILED, FALSE); return BURNERPLAYLIST_STOP;
  989. }
  990. if (BURNERPLAYLIST_SUCCESS != errorCode) // rest of the errors
  991. {
  992. unsigned int strcode(IDS_BURNFAILED);
  993. switch(errorCode)
  994. {
  995. case BURNERPLAYLIST_BEGINBURNFAILED: strcode = IDS_BEGINBURNFAILED; break;
  996. case BURNERPLAYLIST_WRITEAUDIOFAILED: strcode = IDS_WRITEAUDIOFAILED; break;
  997. case BURNERPLAYLIST_ENDBURNFAILED: strcode = IDS_ENDBURNFAILED; break;
  998. }
  999. dlg->ReportError(strcode, FALSE);
  1000. wchar_t caption[64] = {0}, message[512] = {0}, myerror[128] = {0}, libprfx[32] = {0}, liberror[128] = {0}, drvprfx[32] = {0}, drverror[128] = {0};
  1001. LoadStringW(hResource, IDS_BURNERROR, caption, 64);
  1002. LoadStringW(hResource, strcode, myerror, 128);
  1003. LoadStringW(hResource, IDS_LIBERRORPREFIX, libprfx, 32);
  1004. LoadStringW(hResource, IDS_DRVERRORPREFIX, drvprfx, 32);
  1005. GetPrimoCodeText(liberror, 128, (0x000000FF & (((DWORD)param) >> 24)));
  1006. GetUnitStatusText(drverror, 128, (0x000000FF & (((DWORD)param) >> 16)), (0x000000FF & (((DWORD)param) >> 8)), (0x000000FF & (DWORD)param));
  1007. StringCchPrintfW(message, 512, L"%s%s%s%s%s", myerror, libprfx, liberror, drvprfx, drverror);
  1008. MessageBoxW(dlg->hwnd, message, caption, MB_OK | MB_ICONEXCLAMATION);
  1009. return BURNERPLAYLIST_STOP;
  1010. }
  1011. // this is a happy end :)
  1012. if(BST_CHECKED == IsDlgButtonChecked(dlg->hwnd, IDC_CHK_ADDTODB)) dlg->playlist->AddCompilationToCDDB();
  1013. KillTimer(dlg->hwnd, TIMER_UPDATECLOCK_ID);
  1014. dlg->estimatedTime = 0;
  1015. dlg->UpdateTime(FALSE);
  1016. // set caption to the Burning completed.
  1017. {
  1018. wchar_t buffer[128] = {0}, format[128] = {0};
  1019. LoadStringW(hResource, IDS_BURNINGCOMPLETED, format, 128);
  1020. StringCchPrintfW(buffer, 128, format, dlg->drive);
  1021. SetDlgItemTextW(dlg->hwnd, IDC_LBL_CAPTION, buffer);
  1022. }
  1023. dlg->SetCurrentOperation(IDS_BURNSUCCESS);
  1024. dlg->SetReadyClose(TRUE);
  1025. if (dlg->workDone) SetEvent(dlg->workDone);
  1026. if (uMsgBroadcastNotify)
  1027. SendNotifyMessage(HWND_BROADCAST, uMsgBroadcastNotify, (WPARAM)(0xFF & dlg->drive), (LPARAM)FALSE);
  1028. if(BST_CHECKED == IsDlgButtonChecked(dlg->hwnd, IDC_CHK_AUTOCLOSE) ||
  1029. BST_CHECKED == IsDlgButtonChecked(dlg->hwnd, IDC_CHK_HIDEWINDOW))
  1030. {
  1031. PostMessage(dlg->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), (LPARAM)GetDlgItem(dlg->hwnd, IDCANCEL));
  1032. }
  1033. MessageBeep(MB_OK);
  1034. break;
  1035. case BURNERPLAYLIST_BURNCANCELING:
  1036. dlg->SetItemStatusText(((BPLRUNSTATUS*)param)->iIndex,
  1037. (BURNERITEM_CANCELING == dlg->playlist->at(((BPLRUNSTATUS*)param)->iIndex)->GetStatus(NULL)) ? IDS_CANCELING : IDS_CANCELED,
  1038. TRUE);
  1039. if (dlg->ownerWnd) PostMessage(dlg->ownerWnd, WM_BURNNOTIFY, BURN_STATECHANGED, notifyCode);
  1040. break;
  1041. }
  1042. return (!dlg->cancelOp) ? BURNERPLAYLIST_CONTINUE : BURNERPLAYLIST_STOP;
  1043. }
  1044. LRESULT BurnPlaylistUI::WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1045. {
  1046. static BurnPlaylistUI *pl = NULL;
  1047. switch(uMsg)
  1048. {
  1049. case WM_INITDIALOG:
  1050. pl = (BurnPlaylistUI*)lParam;
  1051. pl->OnInitDialog(hwndDlg);
  1052. break;
  1053. case WM_COMMAND:
  1054. switch(LOWORD(wParam))
  1055. {
  1056. case IDCANCEL:
  1057. pl->OnCancel();
  1058. break;
  1059. case IDC_BTN_EXTENDEDVIEW:
  1060. if (BN_CLICKED == HIWORD(wParam)) pl->SetExtendedView(!pl->extendedView);
  1061. break;
  1062. case IDC_BTN_CONTINUE:
  1063. if (BN_CLICKED == HIWORD(wParam))
  1064. {
  1065. wchar_t buffer[128] = {0}, format[128] = {0};
  1066. LoadStringW(hResource, IDS_BURNINGCDDA, format, 128);
  1067. StringCchPrintfW(buffer, 128, format, pl->drive);
  1068. SetDlgItemTextW(hwndDlg, IDC_LBL_CAPTION, buffer);
  1069. LoadStringW(hResource, IDS_CURRENTOPERATION, buffer, 128);
  1070. SetDlgItemTextW(hwndDlg, IDC_LBL_CURRENTOPERATION, buffer);
  1071. ShowWindow((HWND)lParam, SW_HIDE);
  1072. PostMessage(hwndDlg, WM_PLBURNERCOMMAND, PLB_LICENSE, 0);
  1073. }
  1074. break;
  1075. case IDC_CHK_AUTOCLOSE:
  1076. if (BN_CLICKED == HIWORD(wParam))
  1077. {
  1078. if (pl->ownerWnd)
  1079. PostMessage(pl->ownerWnd, WM_BURNNOTIFY,
  1080. BURN_CONFIGCHANGED,
  1081. MAKELPARAM(BURNCFG_AUTOCLOSE, (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHK_AUTOCLOSE))));
  1082. }
  1083. break;
  1084. case IDC_CHK_EJECT:
  1085. if (BN_CLICKED == HIWORD(wParam))
  1086. {
  1087. if (pl->ownerWnd)
  1088. PostMessage(pl->ownerWnd, WM_BURNNOTIFY,
  1089. BURN_CONFIGCHANGED,
  1090. MAKELPARAM(BURNCFG_AUTOEJECT, (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHK_EJECT))));
  1091. }
  1092. break;
  1093. case IDC_CHK_ADDTODB:
  1094. if (BN_CLICKED == HIWORD(wParam))
  1095. {
  1096. if (pl->ownerWnd)
  1097. PostMessage(pl->ownerWnd, WM_BURNNOTIFY,
  1098. BURN_CONFIGCHANGED,
  1099. MAKELPARAM(BURNCFG_ADDTODB, (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHK_ADDTODB))));
  1100. }
  1101. break;
  1102. case IDC_CHK_HIDEWINDOW:
  1103. if (BN_CLICKED == HIWORD(wParam))
  1104. {
  1105. if (pl->ownerWnd)
  1106. PostMessage(pl->ownerWnd, WM_BURNNOTIFY,
  1107. BURN_CONFIGCHANGED,
  1108. MAKELPARAM(BURNCFG_HIDEVIEW, (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEWINDOW))));
  1109. ShowWindow(hwndDlg, (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEWINDOW)) ? SW_HIDE : SW_SHOW);
  1110. }
  1111. break;
  1112. }
  1113. break;
  1114. case WM_DESTROY:
  1115. pl->OnDestroy();
  1116. break;
  1117. case WM_TIMER:
  1118. switch(wParam)
  1119. {
  1120. case TIMER_UPDATECLOCK_ID:
  1121. pl->UpdateTime(FALSE);
  1122. break;
  1123. case TIMER_PROGRESS_ID:
  1124. if (pl->currentPercent == 100) pl->currentPercent = 0;
  1125. pl->SetProgress(pl->currentPercent + 1);
  1126. break;
  1127. }
  1128. break;
  1129. case WM_NOTIFY:
  1130. if (((LPNMHDR)lParam)->idFrom == IDC_LST_DETAILS)
  1131. {
  1132. if(((LPNMHDR)lParam)->code == NM_CUSTOMDRAW)
  1133. {
  1134. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG)(LONG_PTR)pl->DrawList((NMLVCUSTOMDRAW*)lParam));
  1135. return TRUE;
  1136. }
  1137. if(((LPNMHDR)lParam)->code == LVN_ITEMCHANGED)
  1138. {
  1139. int index = (int)SendMessage(((LPNMHDR)lParam)->hwndFrom, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
  1140. if(index == -1) return FALSE;
  1141. ListView_SetItemState(((LPNMHDR)lParam)->hwndFrom, index, 0, LVIS_SELECTED | LVIS_FOCUSED);
  1142. return TRUE;
  1143. }
  1144. }
  1145. break;
  1146. case WM_PLBURNERCOMMAND:
  1147. switch(wParam)
  1148. {
  1149. case PLB_LICENSE:
  1150. pl->OnLicense();
  1151. break;
  1152. case PLB_DECODE:
  1153. pl->OnDecode();
  1154. break;
  1155. case PLB_BURN:
  1156. pl->OnBurn();
  1157. break;
  1158. }
  1159. break;
  1160. case WM_BURNUPDATEOWNER:
  1161. {
  1162. LONG tmpWnd = (LONG)(ULONG_PTR)pl->ownerWnd;
  1163. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, tmpWnd);
  1164. pl->ownerWnd = (HWND)lParam;
  1165. return tmpWnd;
  1166. }
  1167. case WM_BURNGETSTATUS:
  1168. {
  1169. DWORD retCode = 0;
  1170. switch(wParam)
  1171. {
  1172. case BURNSTATUS_DRIVE:
  1173. retCode = pl->drive;
  1174. break;
  1175. case BURNSTATUS_ELAPSED:
  1176. retCode = (GetTickCount() - pl->startedTime)/1000;
  1177. break;
  1178. case BURNSTATUS_ESTIMATED:
  1179. retCode = pl->estimatedTime;
  1180. break;
  1181. case BURNSTATUS_STATE:
  1182. retCode = pl->playlist->GetStatus(NULL);
  1183. break;
  1184. case BURNSTATUS_ERROR:
  1185. pl->playlist->GetStatus(&retCode);
  1186. break;
  1187. case BURNSTATUS_PROGRESS:
  1188. retCode = (GetTickCount() - pl->startedTime)/(pl->estimatedTime*10);
  1189. break;
  1190. }
  1191. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, retCode);
  1192. return retCode;
  1193. }
  1194. case WM_BURNGETITEMSTATUS:
  1195. {
  1196. DWORD retCode = 0;
  1197. if (((DWORD)lParam) >= pl->playlist->GetCount()) break;
  1198. {
  1199. BurnerItem *item = pl->playlist->at(lParam);
  1200. if (!item) break;
  1201. switch(wParam)
  1202. {
  1203. case BURNSTATUS_STATE:
  1204. retCode = item->GetStatus(NULL);
  1205. break;
  1206. case BURNSTATUS_PROGRESS:
  1207. case BURNSTATUS_ERROR:
  1208. item->GetStatus(&retCode);
  1209. break;
  1210. }
  1211. }
  1212. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, retCode);
  1213. return retCode;
  1214. }
  1215. case WM_BURNCONFIGCHANGED:
  1216. switch(wParam)
  1217. {
  1218. case BURNCFG_AUTOCLOSE:
  1219. CheckDlgButton(hwndDlg, IDC_CHK_AUTOCLOSE, (lParam) ? BST_CHECKED : BST_UNCHECKED);
  1220. break;
  1221. case BURNCFG_AUTOEJECT:
  1222. CheckDlgButton(hwndDlg, IDC_CHK_EJECT, (lParam) ? BST_CHECKED : BST_UNCHECKED);
  1223. break;
  1224. case BURNCFG_ADDTODB:
  1225. if (PRIMOSDK_TEST == (pl->burnFlags&PRIMOSDK_TEST)) lParam = FALSE;
  1226. CheckDlgButton(hwndDlg, IDC_CHK_ADDTODB, (lParam) ? BST_CHECKED : BST_UNCHECKED);
  1227. break;
  1228. case BURNCFG_HIDEVIEW:
  1229. CheckDlgButton(hwndDlg, IDC_CHK_HIDEWINDOW, (lParam) ? BST_CHECKED : BST_UNCHECKED);
  1230. break;
  1231. }
  1232. break;
  1233. }
  1234. if (uMsgBroadcastNotify && uMsgBroadcastNotify == uMsg && HIWORD(wParam) && pl && pl->playlist)
  1235. {
  1236. CHAR cLetter;
  1237. cLetter = (CHAR)LOWORD(wParam);
  1238. if (!cLetter || (cLetter == (CHAR)(0xFF & pl->drive)))
  1239. {
  1240. if (!cLetter) cLetter = (CHAR)(0xFF & pl->drive);
  1241. if (BURNERPLAYLIST_BURNFINISHED != pl->playlist->GetStatus(NULL))
  1242. SendNotifyMessage((HWND)lParam, uMsgBroadcastNotify, (WPARAM)cLetter, TRUE);
  1243. }
  1244. }
  1245. return 0;
  1246. }