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.

160 lines
5.4 KiB

  1. #include <windows.h>
  2. #include <port1632.h>
  3. #include <cpl.h>
  4. #include <cphelp.h>
  5. #include "snd.h"
  6. /*---------------------------------------------------------------------------*/
  7. #define NUM_APPLETS 1
  8. /*---------------------------------------------------------------------------*/
  9. typedef struct tagAppletInfo {
  10. int idIcon;
  11. int idName;
  12. int idInfo;
  13. BOOL bEnabled;
  14. DWORD dwContext;
  15. PSTR szHelp;
  16. } APPLET_INFO;
  17. /*---------------------------------------------------------------------------*/
  18. char aszSoundHlp[24];
  19. char aszErrorPlayTitle[32];
  20. char aszErrorPlayMessage[64];
  21. char aszWarningTitle[64];
  22. char aszWarningMessage[128];
  23. char aszNoSound[16];
  24. char aszNoDevice[128];
  25. char aszAppName[30];
  26. char aszWriteErr[100];
  27. DWORD dwContext;
  28. HINSTANCE hInstance;
  29. UINT uHelpMessage;
  30. /*---------------------------------------------------------------------------*/
  31. static SZCODE aszHelpMessage[] = "ShellHelp";
  32. static APPLET_INFO applets[NUM_APPLETS];
  33. /*---------------------------------------------------------------------------*/
  34. BOOL DllInitialize( IN PVOID hmod
  35. , IN DWORD ulReason
  36. , IN PCONTEXT pctx OPTIONAL
  37. )
  38. {
  39. if (ulReason != DLL_PROCESS_ATTACH)
  40. return TRUE;
  41. hInstance = hmod;
  42. applets[0].idIcon = ID_ICON;
  43. applets[0].idName = IDS_NAME;
  44. applets[0].idInfo = IDS_INFO;
  45. applets[0].bEnabled = TRUE;
  46. applets[0].dwContext = IDH_CHILD_SND;
  47. applets[0].szHelp = aszSoundHlp;
  48. LoadString(hInstance, IDS_UNABLETITLE, aszErrorPlayTitle, sizeof(aszErrorPlayTitle));
  49. LoadString(hInstance, IDS_UNABLEMESSAGE, aszErrorPlayMessage, sizeof(aszErrorPlayMessage));
  50. LoadString(hInstance, IDS_WARNINGTITLE, aszWarningTitle, sizeof(aszWarningTitle));
  51. LoadString(hInstance, IDS_WARNINGMESSAGE, aszWarningMessage, sizeof(aszWarningMessage));
  52. LoadString(hInstance, IDS_NONE, aszNoSound, sizeof(aszNoSound));
  53. LoadString(hInstance, IDS_APPNAME, aszAppName, sizeof(aszAppName));
  54. LoadString(hInstance, IDS_HELPFILE, aszSoundHlp, sizeof(aszSoundHlp));
  55. LoadString(hInstance, IDS_NODEVICE, aszNoDevice, sizeof(aszNoDevice));
  56. LoadString(hInstance, IDS_WRITEERR, aszWriteErr, sizeof(aszWriteErr));
  57. return TRUE;
  58. }/* DllInitialize */
  59. /*---------------------------------------------------------------------------*/
  60. static void RunApplet( HWND hwnd, int cmd)
  61. {
  62. dwContext = applets[cmd].dwContext;
  63. DialogBox(hInstance, MAKEINTRESOURCE(DLG_SOUND), hwnd, SoundDlg);
  64. }/* RunApplet */
  65. /*---------------------------------------------------------------------------*/
  66. LRESULT CPlApplet( HWND hwnd
  67. , UINT wMsg
  68. , LPARAM lParam1
  69. , LPARAM lParam2
  70. )
  71. {
  72. LPCPLINFO lpCPlInfo; // was LPNEWCLPINFO in 3.1 -- LKG ???
  73. int iApplet;
  74. switch (wMsg) {
  75. case CPL_INIT:
  76. uHelpMessage = RegisterWindowMessage(aszHelpMessage);
  77. return TRUE;
  78. case CPL_GETCOUNT:
  79. // second message to CPlApplet(), sent once only
  80. return NUM_APPLETS;
  81. case CPL_INQUIRE: // was NEWINQUIRE in 3.1 -- LKG ???
  82. /* third message to CPlApplet(). It is sent as many times
  83. as the number of applets returned by CPL_GETCOUNT message
  84. */
  85. /* Your DLL must contain an icon and two string resources.
  86. idIcon is the icon resource ID, idName and idInfo are
  87. string resource ID's for a short name, and description.
  88. */
  89. lpCPlInfo = (LPCPLINFO)lParam2; // was LPNEWCPLINFO in 3.1 ???
  90. iApplet = (int)(LONG)lParam1;
  91. /***************3.1*******************
  92. lpCPlInfo->hIcon = LoadIcon( hInstance
  93. , MAKEINTRESOURCE(applets[iApplet].idIcon)
  94. );
  95. if ( !LoadString( hInstance
  96. , applets[iApplet].idName
  97. , lpCPlInfo->szName
  98. , sizeof(lpCPlInfo->szName)
  99. )
  100. )
  101. lpCPlInfo->szName[0] = 0;
  102. if( !LoadString( hInstance
  103. , applets[iApplet].idInfo
  104. , lpCPlInfo->szInfo
  105. , sizeof(lpCPlInfo->szInfo)
  106. )
  107. )
  108. lpCPlInfo->szInfo[0] = 0;
  109. lpCPlInfo->dwSize = sizeof(NEWCPLINFO);
  110. lpCPlInfo->dwHelpContext = applets[iApplet].dwContext;
  111. lstrcpy(lpCPlInfo->szHelpFile, applets[iApplet].szHelp);
  112. ************************************/
  113. lpCPlInfo->idIcon = ID_ICON;
  114. lpCPlInfo->idName = IDS_NAME;
  115. lpCPlInfo->lData = (LONG)iApplet;
  116. lpCPlInfo->idInfo = IDS_INFO;
  117. return TRUE;
  118. case CPL_DBLCLK:
  119. RunApplet(hwnd, (int)(LONG)lParam2);
  120. break;
  121. case CPL_SELECT:
  122. /* One of your applets has been selected.
  123. lParam1 is an index from 0 to (NUM_APPLETS-1)
  124. lParam2 is the lData value associated with the applet
  125. */
  126. break;
  127. case CPL_STOP:
  128. /* Sent once for each applet prior to the CPL_EXIT msg.
  129. lParam1 is an index from 0 to (NUM_APPLETS-1)
  130. lParam2 is the lData value associated with the applet
  131. */
  132. break;
  133. case CPL_EXIT:
  134. /* Last message, sent once only, before CONTROL.EXE calls
  135. FreeLibrary() on your DLL.
  136. */
  137. break;
  138. }
  139. return 0;
  140. }/* CPlApplet */