Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.2 KiB

  1. #include "stdafx.h"
  2. #include <windows.h>
  3. #include <commctrl.h>
  4. #include "resource.h"
  5. HANDLE g_hThread = 0;
  6. DWORD g_dwThreadID = 0;
  7. char szProgressText[512];
  8. INT_PTR CALLBACK ProgressDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam,
  9. LPARAM lParam)
  10. {
  11. static HANDLE hEvent;
  12. switch(uiMsg)
  13. {
  14. case WM_INITDIALOG:
  15. hEvent = reinterpret_cast<HANDLE>(lParam);
  16. return TRUE;
  17. case WM_COMMAND:
  18. if(LOWORD(wParam)==IDC_CANCELBUTTON)
  19. SetEvent(hEvent);
  20. break;
  21. default:
  22. return FALSE;
  23. }
  24. return TRUE;
  25. }
  26. DWORD WINAPI ThreadProc(PVOID hEvent)
  27. {
  28. HWND hwDlg = CreateDialogParam(_Module.GetModuleInstance(),
  29. MAKEINTRESOURCE(IDD_PROGRESS), 0, ProgressDlgProc,
  30. reinterpret_cast<LPARAM>(hEvent));
  31. ShowWindow(hwDlg, SW_SHOWNORMAL);
  32. // Add the animation control.
  33. HWND hwChild;
  34. RECT rcChild;
  35. POINT pt;
  36. HWND hwAnim = Animate_Create(hwDlg, 50,
  37. WS_CHILD | ACS_CENTER | ACS_TRANSPARENT, _Module.GetModuleInstance());
  38. hwChild = GetDlgItem(hwDlg, IDC_ANIMHOLDER);
  39. GetWindowRect(hwChild, &rcChild);
  40. DestroyWindow(hwChild);
  41. pt.x = rcChild.left;
  42. pt.y = rcChild.top;
  43. ScreenToClient(hwDlg, &pt);
  44. SetWindowPos(hwAnim, 0, pt.x, pt.y, rcChild.right-rcChild.left,
  45. rcChild.bottom - rcChild.top, SWP_NOZORDER);
  46. Animate_Open(hwAnim, MAKEINTRESOURCE(IDR_PARSING));
  47. Animate_Play(hwAnim, 0, -1, -1);
  48. hwChild = GetDlgItem(hwDlg, IDC_PROGRESSTEXT);
  49. ::SetWindowText(hwChild, szProgressText);
  50. ShowWindow(hwAnim, SW_SHOW);
  51. MSG msg;
  52. while(GetMessage(&msg, 0, 0, 0))
  53. {
  54. if(msg.message == WM_USER + 1)
  55. break;
  56. TranslateMessage(&msg);
  57. DispatchMessage(&msg);
  58. }
  59. return 0;
  60. }
  61. void InitProgressDialog(char* szText, HANDLE hEvent)
  62. {
  63. strcpy(szProgressText, szText);
  64. g_hThread = CreateThread(0, 0, ThreadProc, reinterpret_cast<void*>(hEvent),
  65. 0, &g_dwThreadID);
  66. }
  67. void KillProgressDialog()
  68. {
  69. if(g_hThread)
  70. {
  71. while(!PostThreadMessage(g_dwThreadID, WM_USER+1, 0, 0))
  72. Sleep(0);
  73. CloseHandle(g_hThread);
  74. }
  75. }