Ejemplo n.º 1
0
void CMobileOpalDlg::EnableFullPower()
{
  m_hPowerRequirement = SetPowerRequirement(_T("WAV1:"), D0, POWER_FORCE|POWER_NAME, NULL, 0);
  if (m_hPowerRequirement == NULL)
    MessageBox(_T("Could not set power mode!"));
  SetSystemPowerState(NULL, POWER_STATE_ON, POWER_FORCE);
}
Ejemplo n.º 2
0
//***************************************************************************
// Function Name: SetBacklightRequirement
//
// Purpose: Sets or releases the device power requirement to keep the 
//          backlight at D0
//
// Arguments:
//  IN BOOL fBacklightOn - TRUE to leave the backlight on
//
void SetBacklightRequirement(BOOL fBacklightOn)
{
    // the name of the backlight device
    TCHAR tszBacklightName[] = TEXT("BKL1:"); 

    static HANDLE s_hBacklightReq = NULL;
    
    if (fBacklightOn) 
    {
        if (NULL == s_hBacklightReq) 
        {
            // Set the requirement that the backlight device must remain
            // in device state D0 (full power)
            s_hBacklightReq = SetPowerRequirement(tszBacklightName, D0, 
                                                  POWER_NAME, NULL, 0);
            if (!s_hBacklightReq)
            {
                RETAILMSG(1, (L"SetPowerRequirement failed: %X\n", 
                              GetLastError()));
            }
        }
    } 
    else 
    {
        if (s_hBacklightReq) 
        {
            if (ERROR_SUCCESS != ReleasePowerRequirement(s_hBacklightReq))
            {
                RETAILMSG(1, (L"ReleasePowerRequirement failed: %X\n",
                              GetLastError()));
            }
            s_hBacklightReq = NULL;
        }
    }
}
Ejemplo n.º 3
0
/*!***********************************************************************
 @Function		OsInitOS
 @description	Saves instance handle and creates main window
				In this function, we save the instance handle in a global variable and
				create and display the main program window.
*************************************************************************/
bool PVRShellInit::OsInitOS()
#ifndef NO_GDI
{
	MONITORINFO sMInfo;
	TCHAR		*appName;
	RECT		winRect;
	POINT		p;

	MyRegisterClass();

#ifdef UNDER_CE
	if(!m_pShell->m_pShellData->bUsingPowerSaving)
	{
		/*
			See "Program Applications to Turn the Smartphone Backlight Off and On":
				<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/mob5tskHowToProgramApplicationsToTurnSmartphoneBacklightOffOn.asp>
		*/
		SetPowerRequirement(_T("BKL1:"), D0, POWER_NAME, NULL, 0);

		/*
			It is also necessary to prevent the display driver entering
			power-saving mode.

			The string used here is hard-coded. The following function can
			probably be used to enumerate available strings:
				RequestDeviceNotifications()
		*/
		SetPowerRequirement(_T("{EB91C7C9-8BF6-4a2d-9AB8-69724EED97D1}\\\\Windows\\ddi.dll"), D0, POWER_NAME, NULL, 0);
    }
#endif

	/*
		Build the window title
	*/
	{
		const char		*pszName, *pszSeparator, *pszVersion;
		size_t			len;
		unsigned int	out, in;

		pszName			= (const char*)m_pShell->PVRShellGet(prefAppName);
		pszSeparator	= STR_WNDTITLE;
		pszVersion		= (const char*)m_pShell->PVRShellGet(prefVersion);

		len = strlen(pszName)+strlen(pszSeparator)+strlen(pszVersion)+1;
		appName = new TCHAR[len];

		for(out = 0; (appName[out] = pszName[out]) != 0; ++out);
		for(in = 0; (appName[out] = pszSeparator[in]) != 0; ++in, ++out);
		for(in = 0; (appName[out] = pszVersion[in]) != 0; ++in, ++out);
		_ASSERT(out == len-1);
	}

	/*
		Retrieve the monitor information.

		MonitorFromWindow() doesn't work, because the window hasn't been
		created yet.
	*/
	{
		HMONITOR	hMonitor;
		BOOL		bRet;

		p.x			= m_pShell->m_pShellData->nShellPosX;
		p.y			= m_pShell->m_pShellData->nShellPosY;
		hMonitor	= MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
		sMInfo.cbSize = sizeof(sMInfo);
		bRet = GetMonitorInfo(hMonitor, &sMInfo);
		_ASSERT(bRet);
	}

	/*
		Reduce the window size until it fits on screen
	*/
	while(
		(m_pShell->m_pShellData->nShellDimX > (sMInfo.rcMonitor.right - sMInfo.rcMonitor.left)) ||
		(m_pShell->m_pShellData->nShellDimY > (sMInfo.rcMonitor.bottom - sMInfo.rcMonitor.top)))
	{
		m_pShell->m_pShellData->nShellDimX >>= 1;
		m_pShell->m_pShellData->nShellDimY >>= 1;
	}


	/*
		Create the window
	*/

	if(m_pShell->m_pShellData->bFullScreen)
	{
		m_hWnd = CreateWindow(WINDOW_CLASS, appName, WS_VISIBLE | WS_SYSMENU,CW_USEDEFAULT, CW_USEDEFAULT, m_pShell->m_pShellData->nShellDimX, m_pShell->m_pShellData->nShellDimY,
				NULL, NULL, m_hInstance, this);

		SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~ WS_CAPTION);
		SetWindowPos(m_hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
	}
	else
	{
		int x, y;

		SetRect(&winRect,
			m_pShell->m_pShellData->nShellPosX,
			m_pShell->m_pShellData->nShellPosY,
			m_pShell->m_pShellData->nShellPosX+m_pShell->m_pShellData->nShellDimX,
			m_pShell->m_pShellData->nShellPosY+m_pShell->m_pShellData->nShellDimY);
		AdjustWindowRectEx(&winRect, WS_CAPTION|WS_SYSMENU, false, 0);

		x = m_pShell->m_pShellData->nShellPosX - winRect.left;
		winRect.left += x;
		winRect.right += x;

		y = m_pShell->m_pShellData->nShellPosY - winRect.top;
		winRect.top += y;
		winRect.bottom += y;

		if(m_pShell->m_pShellData->bShellPosWasDefault)
		{
			x = CW_USEDEFAULT;
			y = CW_USEDEFAULT;
		}
		else
		{
			x = winRect.left;
			y = winRect.top;
		}

		m_hWnd = CreateWindow(WINDOW_CLASS, appName, WS_VISIBLE|WS_CAPTION|WS_SYSMENU,
			x, y, winRect.right-winRect.left, winRect.bottom-winRect.top, NULL, NULL, m_hInstance, this);

	}

	if(!m_hWnd)
		return false;

	if(m_pShell->m_pShellData->bFullScreen)
	{
		m_pShell->m_pShellData->nShellDimX = sMInfo.rcMonitor.right;
		m_pShell->m_pShellData->nShellDimY = sMInfo.rcMonitor.bottom;
		SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,0);

#if UNDER_CE == 420 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
		/*
			Fix for 'Top menu-bar' corruption (occurring on exiting egltest in
			fullscreen mode on PocketPC).

			See "How To Create Full-Screen Applications for the PocketPC":
				<http://support.microsoft.com/default.aspx?scid=kb;%5Bln%5D;266244>
		*/
		SetForegroundWindow(m_hWnd);
		SHFullScreen(m_hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
		MoveWindow(m_hWnd,
					sMInfo.rcMonitor.left,
					sMInfo.rcMonitor.top,
					sMInfo.rcMonitor.right,
					sMInfo.rcMonitor.bottom,
					TRUE);
#endif
	}

	m_hDC = GetDC(m_hWnd);
	ShowWindow(m_hWnd, m_nCmdShow);
	UpdateWindow(m_hWnd);

	p.x = 0;
	p.y = 0;
	ClientToScreen(m_hWnd, &p);
	m_pShell->m_pShellData->nShellPosX = p.x;
	m_pShell->m_pShellData->nShellPosY = p.y;

	delete [] appName;
	return true;
}
Ejemplo n.º 4
0
void DoLight()
{
  HANDLE hPower = SetPowerRequirement(TEXT("BKL1:"), D0, POWER_NAME, NULL, 0); 
}