SPLASH.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #define SPLASH_TIMER 34
  10. //#define MODAL_SPLASHSCREEN
  11. static INT_PTR CALLBACK splashFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  12. static int wait;
  13. void splashDlg(int wait_in_ms)
  14. {
  15. wait = wait_in_ms;
  16. #ifdef MODAL_SPLASHSCREEN
  17. DialogBox(hMainInstance, MAKEINTRESOURCE(IDD_SPLASH), NULL, splashFunc);
  18. #else
  19. CreateDialogW(hMainInstance, MAKEINTRESOURCE(IDD_SPLASH), NULL, splashFunc);
  20. #endif
  21. }
  22. static INT_PTR CALLBACK splashFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  23. {
  24. RECT r;
  25. switch (uMsg)
  26. {
  27. case WM_INITDIALOG:
  28. GetWindowRect(GetDlgItem(hwndDlg, IDC_SPLASHIMG), &r);
  29. SetWindowPos(hwndDlg, 0, 0, 0, r.right - r.left, r.bottom - r.top, SWP_NOMOVE | SWP_NOZORDER);
  30. SetTimer(hwndDlg, SPLASH_TIMER, wait, NULL);
  31. return 0;
  32. case WM_KEYDOWN:
  33. case WM_LBUTTONDOWN: case WM_RBUTTONDOWN:
  34. #ifdef MODAL_SPLASHSCREEN
  35. EndDialog(hwndDlg, 0);
  36. #else
  37. DestroyWindow(hwndDlg);
  38. #endif
  39. return 0;
  40. case WM_TIMER:
  41. if (wParam == SPLASH_TIMER)
  42. {
  43. #ifdef MODAL_SPLASHSCREEN
  44. EndDialog(hwndDlg, 1);
  45. #else
  46. DestroyWindow(hwndDlg);
  47. #endif
  48. }
  49. return 0;;
  50. }
  51. return 0;
  52. }