silent.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #include ".\main.h"
  2. #include <commctrl.h>
  3. #include <shlobj.h>
  4. #include "resource.h"
  5. BOOL CALLBACK SilentDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  6. {
  7. switch(uMsg)
  8. {
  9. case WM_INITDIALOG:
  10. {
  11. HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(ICON_XP));
  12. SetClassLongPtr(hwndDlg, GCLP_HICON, (LONG_PTR)hIcon);
  13. HWND hwndPrg = GetDlgItem(hwndDlg, IDC_PRG_COLLECT);
  14. SendMessage(hwndPrg, PBM_SETRANGE, 0, MAKELPARAM(0,100));
  15. SendMessage(hwndPrg, PBM_SETPOS, 0, 0);
  16. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Starting reporter...");
  17. ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON1), SW_HIDE);
  18. ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON2), SW_HIDE);
  19. UpdateWindow(hwndDlg);
  20. if ((settings.createLOG && !settings.ReadLogCollectResult()) &&
  21. (settings.createDMP && !settings.ReadDmpCollectResult()) )
  22. {
  23. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Error. Data was not generated.");
  24. SendMessage(hwndPrg, PBM_SETPOS, 100, 0);
  25. UpdateWindow(hwndDlg);
  26. SetTimer(hwndDlg, 126, 2000, NULL);
  27. break;
  28. }
  29. SetTimer(hwndDlg, 123, 500, NULL);
  30. break;
  31. }
  32. case WM_COMMAND:
  33. switch(LOWORD(wParam))
  34. {
  35. case IDC_BUTTON1:
  36. {
  37. BOOL ret = FALSE;
  38. wchar_t file[MAX_PATH] = {0};
  39. lstrcpyn(file, settings.zipPath, MAX_PATH);
  40. LPSHELLFOLDER pDesktopFolder = 0;
  41. if(SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
  42. {
  43. LPITEMIDLIST filepidl = 0;
  44. HRESULT hr = pDesktopFolder->ParseDisplayName(NULL,0,file,0,&filepidl,0);
  45. if(FAILED(hr)){ pDesktopFolder->Release(); ret = FALSE; }
  46. else
  47. {
  48. if(SUCCEEDED(SHOpenFolderAndSelectItems(filepidl,0,NULL,NULL))){
  49. ret = TRUE;
  50. }
  51. }
  52. }
  53. if (ret == FALSE)
  54. {
  55. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Error. Unable to locate crash report.");
  56. UpdateWindow(hwndDlg);
  57. }
  58. }
  59. break;
  60. case IDCANCEL:
  61. case IDC_BUTTON2:
  62. SetTimer(hwndDlg, 126, 1, NULL);
  63. break;
  64. }
  65. break;
  66. case WM_TIMER:
  67. if (wParam == 123)
  68. {
  69. KillTimer(hwndDlg, wParam);
  70. HWND hwndPrg;
  71. hwndPrg = GetDlgItem(hwndDlg, IDC_PRG_COLLECT);
  72. SendMessage(hwndPrg, PBM_SETPOS, 20, 0);
  73. if (settings.zipData)
  74. {
  75. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Packing results...");
  76. if(!ZipData())
  77. {
  78. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Error. Unable to pack results.");
  79. SendMessage(hwndPrg, PBM_SETPOS, 100, 0);
  80. UpdateWindow(hwndDlg);
  81. SetTimer(hwndDlg, 126, 2000, NULL);
  82. break;
  83. }
  84. }
  85. SendMessage(hwndPrg, PBM_SETPOS, 40, 0);
  86. UpdateWindow(hwndDlg);
  87. if (settings.sendData)
  88. {
  89. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Sending results...");
  90. UpdateWindow(hwndDlg);
  91. if(!SendData(hwndDlg))
  92. {
  93. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Error. Unable to send crash report.");
  94. SendMessage(hwndPrg, PBM_SETPOS, 100, 0);
  95. ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON1), SW_SHOW);
  96. ShowWindow(GetDlgItem(hwndDlg, IDC_BUTTON2), SW_SHOW);
  97. ShowWindow(GetDlgItem(hwndDlg, IDC_PRG_COLLECT), SW_HIDE);
  98. UpdateWindow(hwndDlg);
  99. break;
  100. }
  101. }
  102. if (settings.autoRestart)
  103. {
  104. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Restarting Winamp...");
  105. SendMessage(hwndPrg, PBM_SETPOS, 80, 0);
  106. UpdateWindow(hwndDlg);
  107. if(!Restart())
  108. {
  109. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Error. Unable to restart Winamp.");
  110. SendMessage(hwndPrg, PBM_SETPOS, 100, 0);
  111. UpdateWindow(hwndDlg);
  112. SetTimer(hwndDlg, 126, 2000, NULL);
  113. break;
  114. }
  115. }
  116. SetDlgItemText(hwndDlg, IDC_LBL_STEP, L"Done.");
  117. SendMessage(hwndPrg, PBM_SETPOS, 100, 0);
  118. UpdateWindow(hwndDlg);
  119. SetTimer(hwndDlg, 126, 1000, NULL);
  120. }
  121. else if (wParam == 126)
  122. {
  123. KillTimer(hwndDlg, wParam);
  124. EndDialog(hwndDlg, TRUE);
  125. }
  126. break;
  127. }
  128. return FALSE;
  129. }