home *** CD-ROM | disk | FTP | other *** search
- /*
- SpeedswitchXP V1.4
- - Windows XP CPU Frequency Control for Notebooks -
-
- Copyright(c) 2002-2004 Christian Diefer
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- #include "stdafx.h"
- #include "SpeedswitchXP.h"
- #include "speedswitch.h"
- #include "PowerCapabilities.h"
-
-
- // CPowerCapabilities dialog
-
- IMPLEMENT_DYNAMIC(CPowerCapabilities, CDialog)
- CPowerCapabilities::CPowerCapabilities(CWnd* pParent /*=NULL*/)
- : CDialog(CPowerCapabilities::IDD, pParent)
- , m_szPowerButton(_T(""))
- , m_szSleepButton(_T(""))
- , m_szLidSwitch(_T(""))
- , m_szSStates(_T(""))
- , m_szHiberFile(_T(""))
- , m_szWakeSupport(_T(""))
- , m_szVideoDim(_T(""))
- , m_szAPMBios(_T(""))
- , m_szThermalZones(_T(""))
- , m_szThrottle(_T(""))
- , m_szUPSPresent(_T(""))
- , m_szThrottleMax(_T(""))
- , m_szThrottleMin(_T(""))
- , m_szSpinDown(_T(""))
- , m_szSystemBatteries(_T(""))
- , m_szShortTermBatteries(_T(""))
- { }
-
- CPowerCapabilities::~CPowerCapabilities()
- { }
-
- void CPowerCapabilities::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT16, m_szPowerButton);
- DDX_Text(pDX, IDC_EDIT15, m_szSleepButton);
- DDX_Text(pDX, IDC_EDIT14, m_szLidSwitch);
- DDX_Text(pDX, IDC_EDIT13, m_szSStates);
- DDX_Text(pDX, IDC_EDIT12, m_szHiberFile);
- DDX_Text(pDX, IDC_EDIT11, m_szWakeSupport);
- DDX_Text(pDX, IDC_EDIT10, m_szVideoDim);
- DDX_Text(pDX, IDC_EDIT9, m_szAPMBios);
- DDX_Text(pDX, IDC_EDIT7, m_szThermalZones);
- DDX_Text(pDX, IDC_EDIT4, m_szThrottle);
- DDX_Text(pDX, IDC_EDIT8, m_szUPSPresent);
- DDX_Text(pDX, IDC_EDIT5, m_szThrottleMax);
- DDX_Text(pDX, IDC_EDIT6, m_szThrottleMin);
- DDX_Text(pDX, IDC_EDIT3, m_szSpinDown);
- DDX_Text(pDX, IDC_EDIT2, m_szSystemBatteries);
- DDX_Text(pDX, IDC_EDIT1, m_szShortTermBatteries);
- }
-
-
- BEGIN_MESSAGE_MAP(CPowerCapabilities, CDialog)
- END_MESSAGE_MAP()
-
-
- // CPowerCapabilities message handlers
- BOOL CPowerCapabilities::OnInitDialog()
- {
- CDialog::OnInitDialog();
- return TRUE;
- }
-
- void CPowerCapabilities::setVars()
- {
- BOOL x = (CallNtPowerInformation(SystemPowerCapabilities,
- NULL,
- 0,
- &spc,
- sizeof(spc)) == ERROR_SUCCESS);
- if( x )
- {
- m_szPowerButton = (spc.PowerButtonPresent ? _T("Yes") : _T("No") );
- m_szSleepButton = (spc.SleepButtonPresent ? _T("Yes") : _T("No") );
- m_szLidSwitch = (spc.LidPresent ? _T("Yes") : _T("No") );
-
- char text[128] = "";
- bool first = true;
-
- if( spc.SystemS1 )
- {
- strcat( text, "S1" );
- first = false;
- }
-
- if( spc.SystemS2 )
- {
- if( !first )
- strcat( text, ", " );
- strcat( text, "S2" );
- first = false;
- }
-
- if( spc.SystemS3 )
- {
- if( !first )
- strcat( text, ", " );
- strcat( text, "S3" );
- first = false;
- }
-
- if( spc.SystemS4 )
- {
- if( !first )
- strcat( text, ", " );
- strcat( text, "S4" );
- first = false;
- }
-
- if( spc.SystemS5 )
- {
- if( !first )
- strcat( text, ", " );
- strcat( text, "S5" );
- first = false;
- }
-
- m_szSStates = text;
- m_szHiberFile = (spc.HiberFilePresent ? _T("Yes") : _T("No") );
- m_szWakeSupport = (spc.FullWake ? _T("Yes") : _T("No") );
- m_szVideoDim = (spc.VideoDimPresent ? _T("Yes") : _T("No") );
- m_szAPMBios = (spc.ApmPresent ? _T("Yes") : _T("No") );
- m_szUPSPresent = (spc.UpsPresent ? _T("Yes") : _T("No") );
- m_szThermalZones = (spc.ThermalControl ? _T("Yes") : _T("No") );
-
- BOOLEAN throttle = spc.ProcessorThrottle;
-
- m_szThrottle = (throttle ? _T("Yes") : _T("No") );
-
- if( throttle )
- {
- itoa( spc.ProcessorMinThrottle, text, 10 );
- m_szThrottleMax = text;
-
- itoa( spc.ProcessorMaxThrottle, text, 10 );
- m_szThrottleMin = text;
- }
- else
- {
- m_szThrottleMax = "---";
- m_szThrottleMin = "---";
- }
-
- m_szSpinDown = (spc.DiskSpinDown ? _T("Yes") : _T("No") );
- m_szSystemBatteries = (spc.SystemBatteriesPresent ? _T("Yes") : _T("No") );
- m_szShortTermBatteries = (spc.BatteriesAreShortTerm ? _T("Yes") : _T("No") );
- }
- }