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.

255 lines
6.6 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. m_dwRef--;
  42. if (m_dwRef == 0)
  43. {
  44. delete this;
  45. }
  46. return (m_dwRef);
  47. }
  48. HRESULT CFrameworkNotifySink::OnEvent(MMEVENTS mmEventID, LPVOID pEvent)
  49. {
  50. HRESULT hr = S_OK;
  51. switch (mmEventID)
  52. {
  53. case (MMEVENT_SETTITLE) :
  54. {
  55. MMSETTITLE* pSetTitle = (MMSETTITLE*)pEvent;
  56. if (pSetTitle->mmInfoText == MMINFOTEXT_TITLE)
  57. {
  58. if (m_hwndTitle)
  59. {
  60. _tcscpy(m_pNode->szTitle,pSetTitle->szTitle);
  61. TCHAR szText[MAX_PATH];
  62. wsprintf(szText,TEXT("%s - %s"),pSetTitle->szTitle,m_szAppName);
  63. //only do this if the titles don't match
  64. TCHAR szOrgTitle[MAX_PATH];
  65. GetWindowText(m_hwndTitle,szOrgTitle,sizeof(szOrgTitle)/sizeof(TCHAR));
  66. if (_tcscmp(szOrgTitle,szText)!=0)
  67. {
  68. SetWindowText(m_hwndTitle,szText);
  69. RedrawWindow(m_hwndTitle,NULL,NULL,RDW_FRAME|RDW_INVALIDATE);
  70. if (fShellMode)
  71. {
  72. ShellIconSetTooltip();
  73. } //end if shell mode
  74. }
  75. } //end if window ok
  76. } //end if title
  77. if (pSetTitle->mmInfoText == MMINFOTEXT_DESCRIPTION)
  78. {
  79. if (IsIconic(m_hwndTitle))
  80. {
  81. TCHAR szText[MAX_PATH];
  82. wsprintf(szText,TEXT("%s - %s"),pSetTitle->szTitle,m_szAppName);
  83. SetWindowText(m_hwndTitle,szText);
  84. }
  85. if (fShellMode)
  86. {
  87. ShellIconSetTooltip();
  88. }
  89. } //end if description
  90. }
  91. break;
  92. case (MMEVENT_ONPLAY) :
  93. {
  94. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  95. if (pButton)
  96. {
  97. if (fIntro)
  98. {
  99. pButton->SetIcon(IDI_MODE_INTRO);
  100. pButton->SetToolTipID(IDB_TT_INTRO);
  101. SetWindowText(pButton->GetHWND(),TEXT("2"));
  102. }
  103. else
  104. {
  105. pButton->SetIcon(IDI_ICON_PAUSE);
  106. pButton->SetToolTipID(IDB_TT_PAUSE);
  107. SetWindowText(pButton->GetHWND(),TEXT("1"));
  108. }
  109. }
  110. if (fShellMode)
  111. {
  112. ShellIconSetState(PAUSE_ICON);
  113. } //end if shell mode
  114. fPlaying = TRUE;
  115. }
  116. break;
  117. case (MMEVENT_ONSTOP) :
  118. {
  119. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  120. if (pButton)
  121. {
  122. pButton->SetIcon(IDI_ICON_PLAY);
  123. pButton->SetToolTipID(IDB_TT_PLAY);
  124. SetWindowText(pButton->GetHWND(),TEXT(""));
  125. }
  126. fPlaying = FALSE;
  127. if (fShellMode)
  128. {
  129. ShellIconSetState(PLAY_ICON);
  130. } //end if shell mode
  131. }
  132. break;
  133. case (MMEVENT_ONPAUSE) :
  134. {
  135. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  136. if (pButton)
  137. {
  138. pButton->SetIcon(IDI_ICON_PLAY);
  139. pButton->SetToolTipID(IDB_TT_PLAY);
  140. SetWindowText(pButton->GetHWND(),TEXT(""));
  141. }
  142. fPlaying = FALSE;
  143. if (fShellMode)
  144. {
  145. ShellIconSetState(PLAY_ICON);
  146. } //end if shell mode
  147. }
  148. break;
  149. case (MMEVENT_ONMEDIAUNLOADED) :
  150. {
  151. CMButton* pButton = GetMButtonFromID(m_hwndTitle,IDB_PLAY);
  152. if (pButton)
  153. {
  154. pButton->SetIcon(IDI_ICON_PLAY);
  155. pButton->SetToolTipID(IDB_TT_PLAY);
  156. SetWindowText(pButton->GetHWND(),TEXT(""));
  157. }
  158. fPlaying = FALSE;
  159. if (fShellMode)
  160. {
  161. ShellIconSetState(NODISC_ICON);
  162. } //end if shell mode
  163. }
  164. break;
  165. case (MMEVENT_ONUSERNOTIFY) :
  166. {
  167. }
  168. break;
  169. case (MMEVENT_ONDISCCHANGED) :
  170. {
  171. MMONDISCCHANGED* pDisc = (MMONDISCCHANGED*)pEvent;
  172. SendMessage(m_hwndTitle,WM_DISCCHANGED,pDisc->nNewDisc,pDisc->fDisplayVolChange);
  173. }
  174. break;
  175. }
  176. return hr;
  177. }
  178. void* CFrameworkNotifySink::GetCustomMenu()
  179. {
  180. CustomMenu* pMenu = NULL;
  181. AllocCustomMenu(&pMenu);
  182. return (pMenu);
  183. }
  184. HPALETTE CFrameworkNotifySink::GetPalette()
  185. {
  186. return hpalMain;
  187. }
  188. void* CFrameworkNotifySink::GetOptions()
  189. {
  190. return ((void*)GetCDOpt());
  191. }
  192. void* CFrameworkNotifySink::GetData()
  193. {
  194. return ((void*)GetCDData());
  195. }
  196. ////////////////////////////////////////////////////////////////////////////////////////////
  197. // * GetCDOpt
  198. // Creates or returns the global CDOpt
  199. ////////////////////////////////////////////////////////////////////////////////////////////
  200. LPCDOPT GetCDOpt()
  201. {
  202. if (g_pOptions == NULL)
  203. {
  204. CDOPT_CreateInstance(NULL, IID_ICDOpt, (void**)&g_pOptions);
  205. }
  206. return g_pOptions;
  207. }
  208. ////////////////////////////////////////////////////////////////////////////////////////////
  209. // * GetCDData
  210. // Creates or returns the global CDOpt
  211. ////////////////////////////////////////////////////////////////////////////////////////////
  212. LPCDDATA GetCDData()
  213. {
  214. if (g_pData == NULL)
  215. {
  216. HRESULT hr = CDOPT_CreateInstance(NULL, IID_ICDData, (void**)&g_pData);
  217. }
  218. return g_pData;
  219. }