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.

121 lines
3.0 KiB

  1. //*****************************************************************************
  2. //
  3. // BMTEST.C
  4. //
  5. // DESCRIPTION:
  6. //
  7. //
  8. //*****************************************************************************
  9. #include <nt.h>
  10. #include <ntrtl.h>
  11. #include <nturtl.h>
  12. #include <windows.h>
  13. #include <initguid.h>
  14. #include <devguid.h>
  15. #include <commctrl.h>
  16. typedef LONG NTSTATUS;
  17. #include <cfgmgr32.h>
  18. #include <devioctl.h>
  19. #include <ntpoapi.h>
  20. #include <poclass.h>
  21. #include "batmeter.h"
  22. #include "bmtresid.h"
  23. ULONG _cdecl DbgPrint(PCH Format, ...);
  24. HINSTANCE g_hInstance;
  25. DWORD g_dwCurBat; // Battery we're currently displaying/editing.
  26. PUINT g_puiBatCount;
  27. BOOL g_bShowMulti;
  28. LRESULT CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  29. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
  30. {
  31. BOOL Result;
  32. DWORD Version, dwByteCount;
  33. InitCommonControls();
  34. g_hInstance = hInstance;
  35. // Get the battery count.
  36. if (BatMeterCapabilities(&g_puiBatCount)) {
  37. DialogBox(hInstance,
  38. MAKEINTRESOURCE(IDD_BMTEST),
  39. 0,
  40. DlgProc);
  41. }
  42. return 0;
  43. }
  44. //*****************************************************************************
  45. //
  46. // DlgProc
  47. //
  48. // DESCRIPTION:
  49. //
  50. // PARAMETERS:
  51. //
  52. //*****************************************************************************
  53. LRESULT CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  54. {
  55. static HWND hwndBatMeter;
  56. switch (uMsg) {
  57. case WM_INITDIALOG:
  58. if (*g_puiBatCount > 1) {
  59. CheckDlgButton(hDlg, IDC_ENABLEMULTI, g_bShowMulti);
  60. }
  61. else {
  62. // Battery meter will not run, disable the enable checkbox
  63. EnableWindow(GetDlgItem(hDlg, IDC_ENABLEMULTI), FALSE);
  64. }
  65. hwndBatMeter = CreateBatMeter(hDlg, GetDlgItem(hDlg, IDC_STATIC_FRAME),
  66. g_bShowMulti, NULL);
  67. return TRUE;
  68. case WM_COMMAND:
  69. switch (wParam) {
  70. case IDCANCEL:
  71. case IDOK:
  72. EndDialog(hDlg, 0);
  73. return TRUE ;
  74. case IDC_ENABLEMULTI:
  75. if (IsDlgButtonChecked(hDlg, IDC_ENABLEMULTI)) {
  76. g_bShowMulti = TRUE;
  77. }
  78. else {
  79. g_bShowMulti = FALSE;
  80. }
  81. UpdateBatMeter(hwndBatMeter, g_bShowMulti, TRUE, NULL);
  82. } // switch (wParam)
  83. break;
  84. case WM_POWERBROADCAST:
  85. if (wParam == PBT_APMPOWERSTATUSCHANGE) {
  86. UpdateBatMeter(hwndBatMeter, g_bShowMulti, FALSE, NULL);
  87. }
  88. break;
  89. case WM_DEVICECHANGE:
  90. BatMeterDeviceChanged(0, 0);
  91. break;
  92. } // switch (uMsg)
  93. return FALSE ;
  94. }