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.

198 lines
6.4 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 00
  5. *
  6. * File: powertest.h
  7. *
  8. * Contents: Interface for ACPI test snap-in
  9. *
  10. * History: 29-Feb-2000 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #pragma once
  14. /*+-------------------------------------------------------------------------*
  15. * CPowerTestSnapinItem
  16. *
  17. *
  18. *--------------------------------------------------------------------------*/
  19. class CPowerTestSnapinItem : public CBaseSnapinItem
  20. {
  21. public:
  22. CPowerTestSnapinItem();
  23. BEGIN_COM_MAP(CPowerTestSnapinItem)
  24. COM_INTERFACE_ENTRY(IDataObject) // Cant have empty map so add IDataObject
  25. END_COM_MAP()
  26. public:
  27. virtual const tstring* PstrDisplayName(void);
  28. virtual BOOL FIsContainer(void) { return FALSE; }
  29. virtual BOOL FUsesResultList(void) { return FALSE; }
  30. virtual const CNodeType*Pnodetype(void) { return &nodetypePowerTestRoot; }
  31. virtual SC ScGetField(DAT dat, tstring& strField) { strField.erase(); return S_OK;}
  32. virtual SC ScGetResultViewType(LPOLESTR* ppViewType, long* pViewOptions);
  33. virtual SC ScOnShow(CComponent *pComponent, BOOL fSelect);
  34. virtual SnapinMenuItem *Pmenuitem(void);
  35. virtual INT CMenuItem(void);
  36. virtual SC ScCommand(long nCommandID, CComponent *pComponent = NULL);
  37. virtual DWORD DwFlagsMenuGray(void);
  38. // There is no list-view so following methods are empty.
  39. virtual SC ScInitializeResultView(CComponent *pComponent) { return S_OK;}
  40. virtual SC ScOnAddImages(IImageList* ipResultImageList) { return S_OK;}
  41. private:
  42. // bits returned from DwFlagsMenuGray
  43. enum
  44. {
  45. eFlag_ConsolePowerCreated = 0x00000001,
  46. eFlag_ConsolePowerNotCreated = 0x00000002,
  47. };
  48. std::wstring GetMessageText();
  49. void ReleaseAll ();
  50. void UpdateMessageView ();
  51. SC ScOnCreateConsolePower (CComponent *pComponent);
  52. SC ScOnReleaseConsolePower (CComponent *pComponent);
  53. SC ScOnResetIdleTimer (CComponent *pComponent);
  54. SC ScOnSetExecutionState (CComponent *pComponent);
  55. private:
  56. CComQIPtr<IMessageView> m_spMsgView;
  57. CComPtr<IConsolePower> m_spConsolePower;
  58. CComPtr<IConsolePowerSink> m_spConsolePowerSink;
  59. DWORD m_dwAdviseCookie;
  60. int m_cSystem;
  61. int m_cDisplay;
  62. static SnapinMenuItem s_rgMenuItems[];
  63. };
  64. /*+-------------------------------------------------------------------------*
  65. * CPowerTestConsolePowerSinkImpl
  66. *
  67. *
  68. *--------------------------------------------------------------------------*/
  69. class CPowerTestConsolePowerSinkImpl :
  70. public CComObjectRoot,
  71. public IConsolePowerSink
  72. {
  73. BEGIN_COM_MAP(CPowerTestConsolePowerSinkImpl)
  74. COM_INTERFACE_ENTRY(IConsolePowerSink)
  75. END_COM_MAP()
  76. DECLARE_NOT_AGGREGATABLE(CPowerTestConsolePowerSinkImpl);
  77. public:
  78. STDMETHOD (OnPowerBroadcast)(WPARAM wParam, LPARAM lParam, LRESULT* plResult);
  79. };
  80. /*+-------------------------------------------------------------------------*
  81. * CPowerTestSnapin
  82. *
  83. *
  84. *--------------------------------------------------------------------------*/
  85. class CPowerTestSnapin : public CBaseSnapin
  86. {
  87. typedef CComObject<CSnapinItem<CPowerTestSnapinItem> > t_itemRoot;
  88. SNAPIN_DECLARE( CPowerTestSnapin);
  89. public:
  90. CPowerTestSnapin();
  91. virtual ~CPowerTestSnapin();
  92. // information about the snapin and root (ie initial) node
  93. virtual BOOL FStandalone() {return TRUE;} // only an extension snapin.
  94. virtual BOOL FIsExtension() {return FALSE;}
  95. virtual LONG IdsDescription(void) {return IDS_POWERTESTSNAPIN;}
  96. virtual LONG IdsName(void) {return IDS_POWERTESTSNAPIN;}
  97. virtual SC ScInitBitmaps(void);
  98. const CSnapinInfo * Psnapininfo() {return &snapininfoPowerTest;}
  99. private:
  100. tstring m_strDisplayName;
  101. };
  102. /*+-------------------------------------------------------------------------*
  103. * CPowerTestDlg
  104. *
  105. *
  106. *--------------------------------------------------------------------------*/
  107. class CPowerTestDlg : public CDialogImpl<CPowerTestDlg>
  108. {
  109. public:
  110. CPowerTestDlg(bool fResetTimer = false) :
  111. m_fResetTimer (fResetTimer),
  112. m_dwAdd (0),
  113. m_dwRemove (0)
  114. {}
  115. DWORD GetAddFlags () const { return (m_dwAdd); }
  116. DWORD GetRemoveFlags () const { return (m_dwRemove); }
  117. enum { IDD = IDD_ConsolePowerTest };
  118. BEGIN_MSG_MAP(CPowerTestDlg)
  119. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  120. COMMAND_ID_HANDLER(IDOK, OnOK)
  121. COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
  122. END_MSG_MAP()
  123. // Handler prototypes:
  124. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  125. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  126. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  127. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  128. {
  129. if (m_fResetTimer)
  130. {
  131. SetWindowText (_T("IConsolePower::ResetIdleTimer"));
  132. ::EnableWindow (GetDlgItem (IDC_RemoveGroup), false);
  133. ::EnableWindow (GetDlgItem (IDC_RemoveSystem), false);
  134. ::EnableWindow (GetDlgItem (IDC_RemoveDisplay), false);
  135. }
  136. return 1; // Let the system set the focus
  137. }
  138. LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  139. {
  140. if (IsDlgButtonChecked (IDC_AddSystem)) m_dwAdd |= ES_SYSTEM_REQUIRED;
  141. if (IsDlgButtonChecked (IDC_AddDisplay)) m_dwAdd |= ES_DISPLAY_REQUIRED;
  142. if (IsDlgButtonChecked (IDC_RemoveSystem)) m_dwRemove |= ES_SYSTEM_REQUIRED;
  143. if (IsDlgButtonChecked (IDC_RemoveDisplay)) m_dwRemove |= ES_DISPLAY_REQUIRED;
  144. EndDialog(wID);
  145. return 0;
  146. }
  147. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  148. {
  149. EndDialog(wID);
  150. return 0;
  151. }
  152. private:
  153. const bool m_fResetTimer;
  154. DWORD m_dwAdd;
  155. DWORD m_dwRemove;
  156. };