Leaked source code of windows server 2003
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
8.4 KiB

  1. /*******************************************************************************
  2. *
  3. * Copyright 1999 American Power Conversion, All Rights Reserved
  4. *
  5. * TITLE: UPSINFO.C
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: PaulB
  10. *
  11. * DATE: 07 June, 1999
  12. *
  13. * DESCRIPTION:
  14. ********************************************************************************/
  15. #include "upstab.h"
  16. #include "..\pwrresid.h"
  17. #include "..\PwrMn_cs.h"
  18. #pragma hdrstop
  19. // static data
  20. ///////////////////////////////////////////////////////////////////////////////
  21. static HWND g_hUPSPageWnd = NULL;
  22. static DialogAssociations g_InfoAssocs[] = {
  23. MAKE_ARRAY(VENDOR_NAME, IDS_STRING, IDS_STRING, RESOURCE_FIXED, 0, eDeepGet, 0, 0),
  24. MAKE_ARRAY(MODEL_TYPE, IDS_STRING, IDS_STRING, RESOURCE_FIXED, 0, eDeepGet, 0, 0),
  25. MAKE_ARRAY(SERIAL_NUMBER, IDS_STRING, IDS_STRING, RESOURCE_FIXED, 0, eDeepGet, 0, 0),
  26. MAKE_ARRAY(FIRMWARE_REVISION, IDS_STRING, IDS_STRING, RESOURCE_FIXED, 0, eDeepGet, 0, 0) };
  27. static DWORD g_NoServiceControls[] = { IDC_NO_DETAILED_INFO };
  28. // context-sensitive help table
  29. const DWORD g_UPSInfoHelpIDs[]=
  30. {
  31. IDC_MANUFACTURER_LHS, idh_manufacturer,
  32. IDC_MANUFACTURER, idh_manufacturer,
  33. IDC_MODEL_LHS, idh_model,
  34. IDC_MODEL, idh_model,
  35. IDC_SERIAL_NUMBER_LHS, idh_serialnumber,
  36. IDC_SERIAL_NUMBER, idh_serialnumber,
  37. IDC_FIRMWARE_REVISION_LHS, idh_firmware,
  38. IDC_FIRMWARE_REVISION, idh_firmware,
  39. IDC_UPS_INFO, NO_HELP,
  40. IDC_NO_DETAILED_INFO, NO_HELP,
  41. 0, 0
  42. };
  43. // static functions
  44. ///////////////////////////////////////////////////////////////////////////////
  45. static INT_PTR CALLBACK UPSInfoDlgProc (HWND aDlgHWND,
  46. UINT uMsg,
  47. WPARAM wParam,
  48. LPARAM lParam);
  49. static BOOL UPSInfoDlgHandleInit (HWND aDlgHWND, WPARAM wParam, LPARAM lParam);
  50. static BOOL UPSInfoDlgHandleCommand (HWND aDlgHWND, WPARAM wParam, LPARAM lParam);
  51. ///////////////////////////////////////////////////////////////////////////////
  52. ///////////////////////////////////////////////////////////////////////////////
  53. ///////////////////////////////////////////////////////////////////////////////
  54. //////////////////////////////////////////////////////////////////////////_/_//
  55. //////////////////////////////////////////////////////////////////////////_/_//
  56. // void DisplayUPSInfoDialogBox (HWND aParentWnd);
  57. //
  58. // Description: This function creates and displays the UPS Information dialog
  59. // as a modal dialog. This dialog is displayed when the UPS icon
  60. // button is pressed.
  61. //
  62. // Additional Information:
  63. //
  64. // Parameters:
  65. //
  66. // HWND aParentWnd :- Handle to the parent window.
  67. //
  68. // Return Value: None
  69. //
  70. void DisplayUPSInfoDialogBox (HWND aParentWnd) {
  71. g_hUPSPageWnd = aParentWnd;
  72. DialogBox(GetUPSModuleHandle(), MAKEINTRESOURCE(IDD_UPSDETAILS), aParentWnd, UPSInfoDlgProc);
  73. }
  74. //////////////////////////////////////////////////////////////////////////_/_//
  75. //////////////////////////////////////////////////////////////////////////_/_//
  76. // BOOL CALLBACK UPSInfoDlgProc (HWND aDlgHWND,
  77. // UINT uMsg,
  78. // WPARAM wParam,
  79. // LPARAM lParam);
  80. //
  81. // Description: This is the
  82. // \<A HREF="ms-its:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN98\98VS\1033\winui.chm::/devdoc/live/pdui/dlgboxes_5lib.htm">DialogProc\</A>
  83. // for the UPS Information dialog box.
  84. //
  85. // Additional Information:
  86. //
  87. // Parameters:
  88. //
  89. // HWND aDlgHWND :- Identifies the dialog box.
  90. //
  91. // UINT uMsg :- Specifies the message.
  92. //
  93. // WPARAM wParam :- Specifies additional message-specific information.
  94. //
  95. // LPARAM lParam :- Specifies additional message-specific information.
  96. //
  97. // Return Value: Except in response to the WM_INITDIALOG message, the dialog
  98. // box procedure should return nonzero if it processes the
  99. // message, and zero if it does not.
  100. //
  101. INT_PTR CALLBACK UPSInfoDlgProc (HWND aDlgHWND,
  102. UINT uMsg,
  103. WPARAM wParam,
  104. LPARAM lParam) {
  105. BOOL bRet = TRUE;
  106. switch (uMsg) {
  107. case WM_INITDIALOG: {
  108. //The dialog box procedure should return TRUE to direct the system to
  109. //set the keyboard focus to the control given by wParam.
  110. bRet = UPSInfoDlgHandleInit(aDlgHWND, wParam, lParam);
  111. break;
  112. }
  113. case WM_COMMAND: {
  114. //If an application processes this message, it should return zero.
  115. bRet = UPSInfoDlgHandleCommand(aDlgHWND, wParam, lParam);
  116. break;
  117. }
  118. case WM_HELP: { //Help for WM_HELP says: Returns TRUE
  119. bRet = WinHelp(((LPHELPINFO)lParam)->hItemHandle,
  120. PWRMANHLP,
  121. HELP_WM_HELP,
  122. (ULONG_PTR)(LPTSTR)g_UPSInfoHelpIDs);
  123. break;
  124. }
  125. case WM_CONTEXTMENU: { // right mouse click
  126. bRet = WinHelp((HWND)wParam,
  127. PWRMANHLP,
  128. HELP_CONTEXTMENU,
  129. (ULONG_PTR)(LPTSTR)g_UPSInfoHelpIDs);
  130. break;
  131. }
  132. default: {
  133. bRet = FALSE;
  134. break;
  135. }
  136. } // switch (uMsg)
  137. return(bRet);
  138. }
  139. //////////////////////////////////////////////////////////////////////////_/_//
  140. //////////////////////////////////////////////////////////////////////////_/_//
  141. // BOOL UPSInfoDlgHandleInit (HWND aDlgHWND, WPARAM wParam, LPARAM lParam);
  142. //
  143. // Description: This is the handler function for the UPS Information
  144. // WM_INITDIALOG message.
  145. //
  146. // Additional Information:
  147. //
  148. // Parameters:
  149. //
  150. // HWND aDlgHWND :- Identifies the dialog box.
  151. //
  152. // WPARAM wParam :- Handle of control to receive focus
  153. //
  154. // LPARAM lParam :- Initialization parameter
  155. //
  156. // Return Value: The dialog box procedure should return TRUE to direct the
  157. // system to set the keyboard focus to the control given by
  158. // wParam.
  159. //
  160. BOOL UPSInfoDlgHandleInit (HWND aDlgHWND, WPARAM wParam, LPARAM lParam) {
  161. DoUpdateUPSInfo(aDlgHWND);
  162. return(TRUE);
  163. }
  164. //////////////////////////////////////////////////////////////////////////_/_//
  165. //////////////////////////////////////////////////////////////////////////_/_//
  166. // void DoUpdateUPSInfo (HWND aDlgHWND);
  167. //
  168. // Description: This function updates the information displayed in the
  169. // UPS Information dialog.
  170. //
  171. // Additional Information:
  172. //
  173. // Parameters:
  174. //
  175. // HWND aDlgHWND :- Identifies the dialog box.
  176. //
  177. // Return Value: None
  178. //
  179. void DoUpdateUPSInfo (HWND aDlgHWND) {
  180. static const DWORD numRunningFields = DIMENSION_OF(g_InfoAssocs);
  181. static const DWORD numNoServiceFields = DIMENSION_OF(g_NoServiceControls);
  182. BOOL bShowNoDataItemsField = DoUpdateInfo(aDlgHWND,
  183. g_InfoAssocs,
  184. numRunningFields,
  185. (DWORD *) &g_NoServiceControls,
  186. numNoServiceFields,
  187. TRUE);
  188. ShowWindow(GetDlgItem(aDlgHWND, IDC_NO_DETAILED_INFO), !bShowNoDataItemsField ? SW_SHOW : SW_HIDE);
  189. }
  190. //////////////////////////////////////////////////////////////////////////_/_//
  191. //////////////////////////////////////////////////////////////////////////_/_//
  192. // BOOL UPSInfoDlgHandleCommand (HWND aDlgHWND, WPARAM wParam, LPARAM lParam);
  193. //
  194. // Description: This is the handler function for the APC about box WM_COMMAND
  195. // message.
  196. //
  197. // Additional Information:
  198. //
  199. // Parameters:
  200. //
  201. // HWND aDlgHWND :- Handle to dialog box
  202. //
  203. // WPARAM wParam :- HIWORD(wParam) gives the notification code.
  204. // LOWORD(wParam) gives the control id.
  205. //
  206. // LPARAM lParam :- Gives the HWND or handle of the control.
  207. //
  208. // Return Value: If an application processes this message, it should return 0.
  209. //
  210. BOOL UPSInfoDlgHandleCommand (HWND aDlgHWND, WPARAM wParam, LPARAM lParam) {
  211. BOOL bRes = FALSE;
  212. DWORD ctrlID = LOWORD(wParam);
  213. switch (ctrlID) {
  214. case IDOK:
  215. case IDCANCEL: { //The escape key
  216. EndDialog(aDlgHWND, ctrlID);
  217. break;
  218. }
  219. // case IDB_REFRESH: {
  220. // DoUpdateUPSInfo(aDlgHWND);
  221. // break;
  222. // }
  223. default: {
  224. break;
  225. }
  226. }//end switch
  227. //If an application processes this message, it should return zero.
  228. return(bRes);
  229. }