示例#1
0
static BOOLEAN
CreateEnergyList(HWND hwnd)
{
	BOOLEAN retval;
	POWER_POLICY pp;
	SYSTEM_POWER_CAPABILITIES spc;

	hList = hwnd;

	if (!GetActivePwrScheme(&aps))
		return FALSE;

	if (!ReadGlobalPwrPolicy(&gGPP))
		return FALSE;

	if (!ReadPwrScheme(aps,&pp))
		return FALSE;

	if (!ValidatePowerPolicies(&gGPP,0))
		return FALSE;

/*
	if (!SetActivePwrScheme(aps,&gGPP,&pp))
		return FALSE;
*/

	if (!GetPwrCapabilities(&spc))
		return FALSE;

	if (CanUserWritePwrScheme())
	{
		// TODO:
		// Enable write / delete powerscheme button
	}

	Pos_InitPage(GetParent(hwnd));

	if (!GetActivePwrScheme(&aps))
		return FALSE;

	retval = EnumPwrSchemes(callback_EnumPwrScheme, aps);

    if(SendMessage(hwnd, CB_GETCOUNT, 0, 0) > 0)
    {
        EnableWindow(GetDlgItem(hwndDialog, IDC_DELETE_BTN),TRUE);
		EnableWindow(GetDlgItem(hwndDialog, IDC_SAVEAS_BTN),TRUE);
    }

	return retval;
}
示例#2
0
//------------------------------------------------------------------
// Detect our own profile no
//
// return codes:
//   -1: profile enumeration failed
//   -2: profile not found (profile creation necessary)
//   -3: CPU policy reading from our own profile failed
//   -4: new profile activation failed
//   >=0: profile no (success)
//------------------------------------------------------------------
int detectProfile()
{
  internalProfile = 0xffffffff;
  lastChecked = 0xffffffff;

  if( !EnumPwrSchemes(&powerSchemeCallback,0) )
    return -1;      // enumeration failed

  if( internalProfile == 0xffffffff )
    return -2;      // profile not found

  // read the current CPU policy from our profile
  if( !ReadProcessorPwrScheme(internalProfile,&mach) )
    return -3;      // CPU policy reading failed

  if( !SetActivePwrScheme(internalProfile,NULL,NULL) )
    return -4;  

  updateStates();

  return internalProfile;   // profile found, return profile no
}
示例#3
0
文件: power.cpp 项目: Moteesh/reactos
static
VOID
ShowPowerSchemesPopupMenu(
    CSysTray *pSysTray)
{
    PWRSCHEMECONTEXT PowerSchemeContext = {NULL, 0, 0};
    UINT uiActiveScheme;
    DWORD id;
    POINT pt;
    PowerSchemeContext.hPopup = CreatePopupMenu();
    EnumPwrSchemes(PowerSchemesEnumProc, (LPARAM)&PowerSchemeContext);

    if (GetActivePwrScheme(&uiActiveScheme))
    {
        CheckMenuRadioItem(PowerSchemeContext.hPopup,
                           PowerSchemeContext.uiFirst,
                           PowerSchemeContext.uiLast,
                           uiActiveScheme + 1,
                           MF_BYCOMMAND);
    }

    SetForegroundWindow(pSysTray->GetHWnd());
    GetCursorPos(&pt);
    
    id = TrackPopupMenuEx(PowerSchemeContext.hPopup,
                          TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_BOTTOMALIGN,
                          pt.x,
                          pt.y,
                          pSysTray->GetHWnd(),
                          NULL);

    DestroyMenu(PowerSchemeContext.hPopup);

    if (id != 0)
        SetActivePwrScheme(id - 1, NULL, NULL);
}