home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 March / PCpro_2005_03.ISO / files / systools / speedswitchxp / sswitchxp14.exe / Typical / PowerCapabilities.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-01-14  |  4.8 KB  |  170 lines

  1. /*
  2.    SpeedswitchXP V1.4
  3.    - Windows XP CPU Frequency Control for Notebooks -
  4.  
  5.    Copyright(c) 2002-2004 Christian Diefer
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License version 2 as 
  9.    published by the Free Software Foundation.
  10.    
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.    
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #include "stdafx.h"
  22. #include "SpeedswitchXP.h"
  23. #include "speedswitch.h"
  24. #include "PowerCapabilities.h"
  25.  
  26.  
  27. // CPowerCapabilities dialog
  28.  
  29. IMPLEMENT_DYNAMIC(CPowerCapabilities, CDialog)
  30. CPowerCapabilities::CPowerCapabilities(CWnd* pParent /*=NULL*/)
  31.     : CDialog(CPowerCapabilities::IDD, pParent)
  32.   , m_szPowerButton(_T(""))
  33.   , m_szSleepButton(_T(""))
  34.   , m_szLidSwitch(_T(""))
  35.   , m_szSStates(_T(""))
  36.   , m_szHiberFile(_T(""))
  37.   , m_szWakeSupport(_T(""))
  38.   , m_szVideoDim(_T(""))
  39.   , m_szAPMBios(_T(""))
  40.   , m_szThermalZones(_T(""))
  41.   , m_szThrottle(_T(""))
  42.   , m_szUPSPresent(_T(""))
  43.   , m_szThrottleMax(_T(""))
  44.   , m_szThrottleMin(_T(""))
  45.   , m_szSpinDown(_T(""))
  46.   , m_szSystemBatteries(_T(""))
  47.   , m_szShortTermBatteries(_T(""))
  48. { }
  49.  
  50. CPowerCapabilities::~CPowerCapabilities()
  51. { }
  52.  
  53. void CPowerCapabilities::DoDataExchange(CDataExchange* pDX)
  54. {
  55.   CDialog::DoDataExchange(pDX);
  56.   DDX_Text(pDX, IDC_EDIT16, m_szPowerButton);
  57.   DDX_Text(pDX, IDC_EDIT15, m_szSleepButton);
  58.   DDX_Text(pDX, IDC_EDIT14, m_szLidSwitch);
  59.   DDX_Text(pDX, IDC_EDIT13, m_szSStates);
  60.   DDX_Text(pDX, IDC_EDIT12, m_szHiberFile);
  61.   DDX_Text(pDX, IDC_EDIT11, m_szWakeSupport);
  62.   DDX_Text(pDX, IDC_EDIT10, m_szVideoDim);
  63.   DDX_Text(pDX, IDC_EDIT9, m_szAPMBios);
  64.   DDX_Text(pDX, IDC_EDIT7, m_szThermalZones);
  65.   DDX_Text(pDX, IDC_EDIT4, m_szThrottle);
  66.   DDX_Text(pDX, IDC_EDIT8, m_szUPSPresent);
  67.   DDX_Text(pDX, IDC_EDIT5, m_szThrottleMax);
  68.   DDX_Text(pDX, IDC_EDIT6, m_szThrottleMin);
  69.   DDX_Text(pDX, IDC_EDIT3, m_szSpinDown);
  70.   DDX_Text(pDX, IDC_EDIT2, m_szSystemBatteries);
  71.   DDX_Text(pDX, IDC_EDIT1, m_szShortTermBatteries);
  72. }
  73.  
  74.  
  75. BEGIN_MESSAGE_MAP(CPowerCapabilities, CDialog)
  76. END_MESSAGE_MAP()
  77.  
  78.  
  79. // CPowerCapabilities message handlers
  80. BOOL CPowerCapabilities::OnInitDialog()
  81. {
  82.   CDialog::OnInitDialog();
  83.   return TRUE;
  84. }
  85.  
  86. void CPowerCapabilities::setVars()
  87. {
  88.   BOOL x = (CallNtPowerInformation(SystemPowerCapabilities,
  89.                                    NULL,
  90.                                    0,
  91.                                    &spc,
  92.                                    sizeof(spc)) == ERROR_SUCCESS);
  93.   if( x )
  94.   {
  95.     m_szPowerButton = (spc.PowerButtonPresent ? _T("Yes") : _T("No") );
  96.     m_szSleepButton = (spc.SleepButtonPresent ? _T("Yes") : _T("No") );
  97.     m_szLidSwitch = (spc.LidPresent ? _T("Yes") : _T("No") );
  98.  
  99.     char text[128] = "";
  100.     bool first = true;
  101.  
  102.     if( spc.SystemS1 ) 
  103.     {
  104.       strcat( text, "S1" );
  105.       first = false;
  106.     }
  107.  
  108.     if( spc.SystemS2 )
  109.     {
  110.       if( !first )
  111.         strcat( text, ", " );
  112.       strcat( text, "S2" );
  113.       first = false;
  114.     }
  115.  
  116.     if( spc.SystemS3 )
  117.     {
  118.       if( !first )
  119.         strcat( text, ", " );
  120.       strcat( text, "S3" );
  121.       first = false;
  122.     }
  123.  
  124.     if( spc.SystemS4 )
  125.     {
  126.       if( !first )
  127.         strcat( text, ", " );
  128.       strcat( text, "S4" );
  129.       first = false;
  130.     }
  131.  
  132.     if( spc.SystemS5 )
  133.     {
  134.       if( !first )
  135.         strcat( text, ", " );
  136.       strcat( text, "S5" );
  137.       first = false;
  138.     }
  139.     
  140.     m_szSStates = text;
  141.     m_szHiberFile = (spc.HiberFilePresent ? _T("Yes") : _T("No") );
  142.     m_szWakeSupport = (spc.FullWake ? _T("Yes") : _T("No") );
  143.     m_szVideoDim = (spc.VideoDimPresent ? _T("Yes") : _T("No") );
  144.     m_szAPMBios = (spc.ApmPresent ? _T("Yes") : _T("No") );
  145.     m_szUPSPresent = (spc.UpsPresent ? _T("Yes") : _T("No") );
  146.     m_szThermalZones = (spc.ThermalControl ? _T("Yes") : _T("No") );
  147.  
  148.     BOOLEAN throttle = spc.ProcessorThrottle;
  149.  
  150.     m_szThrottle = (throttle ? _T("Yes") : _T("No") );
  151.  
  152.     if( throttle )
  153.     {
  154.       itoa( spc.ProcessorMinThrottle, text, 10 );
  155.       m_szThrottleMax = text;
  156.  
  157.       itoa( spc.ProcessorMaxThrottle, text, 10 );
  158.       m_szThrottleMin = text;
  159.     }
  160.     else
  161.     {
  162.       m_szThrottleMax = "---";
  163.       m_szThrottleMin = "---";
  164.     }
  165.  
  166.     m_szSpinDown = (spc.DiskSpinDown ? _T("Yes") : _T("No") );
  167.     m_szSystemBatteries = (spc.SystemBatteriesPresent ? _T("Yes") : _T("No") );
  168.     m_szShortTermBatteries = (spc.BatteriesAreShortTerm ? _T("Yes") : _T("No") );
  169.   }
  170. }