Source code of Windows XP (NT5)
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.

257 lines
6.5 KiB

  1. // FrameworkNotifySink.cpp: implementation of the CFrameworkNotifySink class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include <windows.h>
  5. #include <tchar.h>
  6. #include "sink.h"
  7. #include "mbutton.h"
  8. #include "resource.h"
  9. #include "mmenu.h"
  10. #include "shellico.h"
  11. //////////////////////////////////////////////////////////////////////
  12. // Construction/Destruction
  13. //////////////////////////////////////////////////////////////////////
  14. HWND CFrameworkNotifySink::m_hwndTitle = NULL;
  15. extern BOOL fPlaying;
  16. extern BOOL fIntro;
  17. extern BOOL fShellMode;
  18. extern HPALETTE hpalMain; //main palette of app
  19. extern LPCDOPT g_pOptions;
  20. extern LPCDDATA g_pData;
  21. extern HWND hwndMain;
  22. CFrameworkNotifySink::CFrameworkNotifySink(PCOMPNODE pNode)
  23. {
  24. m_dwRef = 0;
  25. m_pNode = pNode;
  26. LoadString(NULL,IDS_APPNAME,m_szAppName,sizeof(m_szAppName)/sizeof(TCHAR));
  27. }
  28. CFrameworkNotifySink::~CFrameworkNotifySink()
  29. {
  30. }
  31. HRESULT CFrameworkNotifySink::QueryInterface(REFIID riid, LPVOID *ppvObj)
  32. {
  33. return S_OK;
  34. }
  35. ULONG CFrameworkNotifySink::AddRef()
  36. {
  37. return (m_dwRef++);
  38. }
  39. ULONG CFrameworkNotifySink::Release()
  40. {
  41. if (0!=--m_dwRef)
  42. return m_dwRef;
  43. delete this;
  44. return 0;
  45. }
  46. HRESULT CFrameworkNotifySink::OnEvent(MMEVENTS mmEventID, LPVOID pEvent)
  47. {
  48. HRESULT hr = S_OK;
  49. switch (mmEventID)
  50. {
  51. case (MMEVENT_SETTITLE) :
  52. {
  53. MMSETTITLE* pSetTitle = (MMSETTITLE*)pEvent;
  54. if (pSetTitle->mmInfoText == MMINFOTEXT_TITLE)
  55. {
  56. if (m_hwndTitle)
  57. {
  58. _tcscpy(m_pNode->szTitle,pSetTitle->szTitle);
  59. TCHAR szText[MAX_PATH];
  60. wsprintf(szText,TEXT("%s - %s"),pSetTitle->szTitle,m_szAppName);
  61. //only do this if the titles don't match
  62. TCHAR szOrgTitle[MAX_PATH];
  63. GetWindowText(m_hwndTitle,szOrgTitle,sizeof(szOrgTitle)/sizeof(TCHAR));
  64. if (_tcscmp(szOrgTitle,szText)!=0)
  65. {
  66. SetWindowText(m_hwndTitle,szText);
  67. RedrawWindow(m_hwndTitle,NULL,NULL,RDW_FRAME|RDW_INVALIDATE);
  68. if (fShellMode)
  69. {
  70. ShellIconSetTooltip();
  71. } //end if shell mode
  72. }
  73. } //end if window ok
  74. } //end if title
  75. if (pSetTitle->mmInfoText == MMINFOTEXT_DESCRIPTION)
  76. {
  77. if (IsIconic(m_hwndTitle))
  78. {
  79. TCHAR szText[MAX_PATH];
  80. wsprintf(szText,TEXT("%s - %s"),pSetTitle->szTitle,m_szAppName);
  81. SetWindowText(m_hwndTitle,szText);
  82. }
  83. if (fShellMode)
  84. {
  85. ShellIconSetTooltip();
  86. }
  87. } //end if description
  88. }
  89. break;
  90. case (MMEVENT_ONPLAY) :
  91. {
  92. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  93. if (pButton)
  94. {
  95. if (fIntro)
  96. {
  97. pButton->SetIcon(IDI_MODE_INTRO);
  98. pButton->SetToolTipID(IDB_TT_INTRO);
  99. }
  100. else
  101. {
  102. pButton->SetIcon(IDI_ICON_PAUSE);
  103. pButton->SetToolTipID(IDB_TT_PAUSE);
  104. }
  105. }
  106. if (fShellMode)
  107. {
  108. ShellIconSetState(PAUSE_ICON);
  109. } //end if shell mode
  110. SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
  111. fPlaying = TRUE;
  112. }
  113. break;
  114. case (MMEVENT_ONSTOP) :
  115. {
  116. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  117. if (pButton)
  118. {
  119. pButton->SetIcon(IDI_ICON_PLAY);
  120. pButton->SetToolTipID(IDB_TT_PLAY);
  121. }
  122. SetThreadExecutionState(ES_CONTINUOUS);
  123. fPlaying = FALSE;
  124. if (fShellMode)
  125. {
  126. ShellIconSetState(PLAY_ICON);
  127. } //end if shell mode
  128. }
  129. break;
  130. case (MMEVENT_ONPAUSE) :
  131. {
  132. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  133. if (pButton)
  134. {
  135. pButton->SetIcon(IDI_ICON_PLAY);
  136. pButton->SetToolTipID(IDB_TT_PLAY);
  137. }
  138. SetThreadExecutionState(ES_CONTINUOUS);
  139. fPlaying = FALSE;
  140. if (fShellMode)
  141. {
  142. ShellIconSetState(PLAY_ICON);
  143. } //end if shell mode
  144. }
  145. break;
  146. case (MMEVENT_ONMEDIAUNLOADED) :
  147. {
  148. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  149. if (pButton)
  150. {
  151. pButton->SetIcon(IDI_ICON_PLAY);
  152. pButton->SetToolTipID(IDB_TT_PLAY);
  153. }
  154. SetThreadExecutionState(ES_CONTINUOUS);
  155. fPlaying = FALSE;
  156. if (fShellMode)
  157. {
  158. ShellIconSetState(NODISC_ICON);
  159. } //end if shell mode
  160. }
  161. break;
  162. case (MMEVENT_ONUSERNOTIFY) :
  163. {
  164. }
  165. break;
  166. case (MMEVENT_ONDISCCHANGED) :
  167. {
  168. MMONDISCCHANGED* pDisc = (MMONDISCCHANGED*)pEvent;
  169. SendMessage(m_hwndTitle,WM_DISCCHANGED,pDisc->nNewDisc,pDisc->fDisplayVolChange);
  170. }
  171. break;
  172. }
  173. return hr;
  174. }
  175. void* CFrameworkNotifySink::GetCustomMenu()
  176. {
  177. CustomMenu* pMenu = NULL;
  178. AllocCustomMenu(&pMenu);
  179. return (pMenu);
  180. }
  181. HPALETTE CFrameworkNotifySink::GetPalette()
  182. {
  183. return hpalMain;
  184. }
  185. void* CFrameworkNotifySink::GetOptions()
  186. {
  187. return ((void*)GetCDOpt());
  188. }
  189. void* CFrameworkNotifySink::GetData()
  190. {
  191. return ((void*)GetCDData());
  192. }
  193. ////////////////////////////////////////////////////////////////////////////////////////////
  194. // * GetCDOpt
  195. // Creates or returns the global CDOpt
  196. ////////////////////////////////////////////////////////////////////////////////////////////
  197. LPCDOPT GetCDOpt()
  198. {
  199. if (g_pOptions == NULL)
  200. {
  201. CDOPT_CreateInstance(NULL, IID_ICDOpt, (void**)&g_pOptions);
  202. }
  203. return g_pOptions;
  204. }
  205. ////////////////////////////////////////////////////////////////////////////////////////////
  206. // * GetCDData
  207. // Creates or returns the global CDOpt
  208. ////////////////////////////////////////////////////////////////////////////////////////////
  209. LPCDDATA GetCDData()
  210. {
  211. if (g_pData == NULL)
  212. {
  213. HRESULT hr = CDOPT_CreateInstance(NULL, IID_ICDData, (void**)&g_pData);
  214. }
  215. return g_pData;
  216. }