1
0

main_close.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 "wa_dlg.h"
  10. #include "./api.h"
  11. // Destroy handler
  12. int Main_OnDestroy(HWND hwnd)
  13. {
  14. if (NULL != WASABI_API_APP) WASABI_API_APP->app_unregisterGlobalWindow(hwnd);
  15. if (g_main_created)
  16. {
  17. SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS);
  18. Main_OnEndSession(NULL,TRUE);
  19. PostQuitMessage(0);
  20. }
  21. return 1;
  22. }
  23. int Main_OnClose(HWND hwnd)
  24. {
  25. if (g_exit_disabled)
  26. {
  27. if (NULL != WASABI_API_APP)
  28. WASABI_API_APP->main_cancelShutdown();
  29. return 0;
  30. }
  31. ReleaseCapture();
  32. if (!SendMessageW(hwnd,WM_WA_IPC,0,IPC_HOOK_OKTOQUIT))
  33. {
  34. if (NULL != WASABI_API_APP)
  35. WASABI_API_APP->main_cancelShutdown();
  36. return 0;
  37. }
  38. if (playing) StopPlaying(1);
  39. sa_setthread(-1);
  40. vis_stop();
  41. dsp_quit();
  42. if (pTaskbar3 != NULL)
  43. pTaskbar3->Release();
  44. pTaskbar3=0;
  45. if (toolbarIcons)
  46. ImageList_Destroy(toolbarIcons);
  47. toolbarIcons = 0;
  48. DestroyWindow(hwnd);
  49. return 0;
  50. }
  51. void Main_OnEndSession(HWND hwnd, BOOL fEnding)
  52. {
  53. // TODO try to make this match normal shutdown...
  54. if (fEnding)
  55. {
  56. EndFullscreenAppMonitor();
  57. if (playing) StopPlaying(1);
  58. sa_setthread(-1);
  59. vis_stop();
  60. dsp_quit();
  61. if (!hwnd && systray_intray) systray_restore();
  62. hEQWindow=hPLWindow=/*hMBWindow=*/hVideoWindow=0;
  63. hVisWindow=0;
  64. hPLVisWindow=0;
  65. draw_kill();
  66. draw_finalquit();
  67. WADlg_close();
  68. Skin_CleanupZip();
  69. // is possible the prefs window was open but has already been destroyed
  70. // so don't use IsWindow(..) here and instead just look if its non-null
  71. if (prefs_hwnd)
  72. {
  73. prefs_hwnd = 0;
  74. config_write(2);
  75. }
  76. else config_write(1);
  77. stats_write();
  78. PlayList_destroy();
  79. PlayList_randpos(-666);
  80. DestroyMenu(top_menu);
  81. if (hwnd) unload_genplugins();
  82. out_deinit();
  83. in_deinit();
  84. Lang_EndLangSupport();
  85. Lang_CleanupZip();
  86. // if we're working on a delayed saving of language pack change then now
  87. if(config_langpack2[0]){
  88. // if < is the buffer contents then we're setting it back to the base support
  89. if(config_langpack2[0] == '<') config_langpack2[0] = 0;
  90. lstrcpynW(config_langpack,config_langpack2,MAX_PATH);
  91. config_save_langpack_var();
  92. }
  93. }
  94. }