• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ChangeDisplaySettingsEx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ChangeDisplaySettingsEx函数的典型用法代码示例。如果您正苦于以下问题:C++ ChangeDisplaySettingsEx函数的具体用法?C++ ChangeDisplaySettingsEx怎么用?C++ ChangeDisplaySettingsEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ChangeDisplaySettingsEx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: memset

void CRotateDispWnd::ChangeDispById(int angle)
{
	int ScrWidth,ScrHeight;
	DEVMODE DevMode;
	bool HToW;
	
	ScrWidth=GetSystemMetrics(SM_CXSCREEN);
	ScrHeight=GetSystemMetrics(SM_CYSCREEN);
	HToW= ScrHeight > ScrWidth;
	memset(&DevMode,0,sizeof(DevMode));
	DevMode.dmSize=sizeof(DevMode);
#define DM_DISPLAYORIENTATION   0x00000080L
	DevMode.dmFields=DM_DISPLAYORIENTATION;
	DevMode.dmScale=angle;
	if(angle == ANG_90 || angle == ANG_270)
		HToW=!HToW;
	if(HToW)
	{
		DevMode.dmFields=DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT;
		DevMode.dmPelsWidth=ScrHeight;
		DevMode.dmPelsHeight=ScrWidth;
	}
	if(!ChangeDisplaySettingsEx(NULL,&DevMode,NULL,CDS_TEST,0))
		ChangeDisplaySettingsEx(NULL,&DevMode,NULL,CDS_UPDATEREGISTRY | CDS_GLOBAL | CDS_RESET,0);
}
开发者ID:drupalhunter,项目名称:Reverse-Engineearing,代码行数:25,代码来源:RotateDispWnd.cpp


示例2: SetFullscreen

static bool APIENTRY SetFullscreen(const char *devicename, int w, int h, int bits, int hz)
{
	DEVMODE dm;

	if (w==0)
	{
		ChangeDisplaySettingsEx(devicename, 0, 0, 0, 0);
	}
	else
	{
		dm.dmSize = sizeof(DEVMODE);
		dm.dmSpecVersion = DM_SPECVERSION;//Somebody owes me...
		dm.dmDriverExtra = 0;//...1 hour of my life back
		dm.dmPelsWidth = w;
		dm.dmPelsHeight = h;
		dm.dmBitsPerPel = bits;
		dm.dmDisplayFrequency = hz;
		dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
		if (DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0))
		{
			dm.dmFields &= ~DM_DISPLAYFREQUENCY;
			return DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0);
		}
	}
	return true;
}
开发者ID:alexey-lysiuk,项目名称:gzdoom-osx,代码行数:26,代码来源:gl_interface.cpp


示例3: WIN_SetDisplayMode

int
WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
    SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
    LONG status;

    if (mode->driverdata == display->desktop_mode.driverdata) {
        status = ChangeDisplaySettingsEx(displaydata->DeviceName, NULL, NULL, 0, NULL);
    } else {
        status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL);
    }
    if (status != DISP_CHANGE_SUCCESSFUL) {
        const char *reason = "Unknown reason";
        switch (status) {
        case DISP_CHANGE_BADFLAGS:
            reason = "DISP_CHANGE_BADFLAGS";
            break;
        case DISP_CHANGE_BADMODE:
            reason = "DISP_CHANGE_BADMODE";
            break;
        case DISP_CHANGE_BADPARAM:
            reason = "DISP_CHANGE_BADPARAM";
            break;
        case DISP_CHANGE_FAILED:
            reason = "DISP_CHANGE_FAILED";
            break;
        }
        return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
    }
    EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
    return 0;
}
开发者ID:LibreGames,项目名称:caveexpress,代码行数:33,代码来源:SDL_windowsmodes.c


示例4: GetSystemMetrics

bool
Display::Rotate(enum orientation orientation)
{
  if (orientation == ORIENTATION_DEFAULT)
    /* leave it as it is */
    return true;

#ifdef ROTATE_SUPPORTED
  unsigned width = GetSystemMetrics(SM_CXSCREEN);
  unsigned height = GetSystemMetrics(SM_CYSCREEN);
  if (width == height)
    /* cannot rotate a square display */
    return false;

  if (width < height) {
    /* portrait currently */
    if (orientation == ORIENTATION_PORTRAIT)
      return true;
  } else {
    /* landscape currently */
    if (orientation == ORIENTATION_LANDSCAPE)
      return true;
  }

  DEVMODE DeviceMode;
  memset(&DeviceMode, 0, sizeof(DeviceMode));
  DeviceMode.dmSize = sizeof(DeviceMode);
  DeviceMode.dmFields = DM_DISPLAYORIENTATION;

  /* get current rotation */

  if (ChangeDisplaySettingsEx(NULL, &DeviceMode, NULL,
                              CDS_TEST, NULL) != DISP_CHANGE_SUCCESSFUL)
    return false;

  /* determine the new rotation */

  switch (DeviceMode.dmDisplayOrientation) {
  case DMDO_0:
  case DMDO_180:
    DeviceMode.dmDisplayOrientation = DMDO_90;
    break;

  case DMDO_90:
  case DMDO_270:
    DeviceMode.dmDisplayOrientation = DMDO_0;
    break;

  default:
    return false;
  }

  /* apply the new rotation */

  return ChangeDisplaySettingsEx(NULL, &DeviceMode, NULL,
                                 CDS_RESET, NULL) == DISP_CHANGE_SUCCESSFUL;
#else
  return false;
#endif
}
开发者ID:hnpilot,项目名称:XCSoar,代码行数:60,代码来源:Display.cpp


示例5: ZeroMemory

bool GenericSLM::DetachDisplayDevice(MonitorDevice * dev) {
   int result;
   DEVMODE    DevMode;
   ZeroMemory(&DevMode, sizeof(DevMode));
   DevMode.dmSize = sizeof(DevMode);
   DevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_POSITION
               | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS ;
   result = ChangeDisplaySettingsEx(dev->cardName.c_str(), &DevMode, NULL, CDS_UPDATEREGISTRY, NULL);
   result = ChangeDisplaySettingsEx(dev->cardName.c_str(), &DevMode, NULL, CDS_UPDATEREGISTRY, NULL);
   dev->isDisabled = true;

   updateMonitorRects(&displays_);
   return true;
}
开发者ID:bwagjor,项目名称:Thesis,代码行数:14,代码来源:GenericSLM.cpp


示例6: _glfwSetVideoMode

int _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode)
{
    GLFWvidmode current;
    const GLFWvidmode* best;
    DEVMODE dm;

    best = _glfwChooseVideoMode(monitor, mode);

    _glfwPlatformGetVideoMode(monitor, &current);
    if (_glfwCompareVideoModes(&current, best) == 0)
        return GL_TRUE;

    dm.dmSize = sizeof(DEVMODE);
    dm.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
    dm.dmPelsWidth  = best->width;
    dm.dmPelsHeight = best->height;
    dm.dmBitsPerPel = best->redBits + best->greenBits + best->blueBits;

    if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
        dm.dmBitsPerPel = 32;

    if (ChangeDisplaySettingsEx(monitor->win32.name,
                                &dm,
                                NULL,
                                CDS_FULLSCREEN,
                                NULL) != DISP_CHANGE_SUCCESSFUL)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to set video mode");
        return GL_FALSE;
    }

    return GL_TRUE;
}
开发者ID:csulmone,项目名称:glfw,代码行数:33,代码来源:win32_monitor.c


示例7: gfx_ctx_destroy

static void gfx_ctx_destroy(void)
{
   if (g_hrc)
   {
      wglMakeCurrent(NULL, NULL);
      wglDeleteContext(g_hrc);
      g_hrc = NULL;
   }

   if (g_hwnd && g_hdc)
   {
      ReleaseDC(g_hwnd, g_hdc);
      g_hdc = NULL;
   }

   if (g_hwnd)
   {
      g_last_hm = MonitorFromWindow(g_hwnd, MONITOR_DEFAULTTONEAREST);
      DestroyWindow(g_hwnd);
      UnregisterClass("RetroArch", GetModuleHandle(NULL));
      g_hwnd = NULL;
   }

   if (g_restore_desktop)
   {
      MONITORINFOEX current_mon;
      memset(&current_mon, 0, sizeof(current_mon));
      current_mon.cbSize = sizeof(MONITORINFOEX);
      GetMonitorInfo(g_last_hm, (MONITORINFO*)&current_mon);
      ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
      g_restore_desktop = false;
   }

   g_inited = false;
}
开发者ID:Jalle19,项目名称:RetroArch,代码行数:35,代码来源:wgl_ctx.c


示例8: Rotate

static BOOL Rotate( int iDevNum,  SHORT dmOrientation )
{
    DISPLAY_DEVICE d;
    DEVMODE dm;
    int w;
    LONG r;

    ZeroMemory( &d, sizeof( d ) );
    d.cb = sizeof( d );

    if( !EnumDisplayDevices( NULL, iDevNum, &d, 0 ) ) {
        DebugMsg( _T("EnumDisplayDevices failed:%d\r\n" ), GetLastError() );
        return FALSE;
    }

    if( !EnumDisplaySettings( d.DeviceName, ENUM_CURRENT_SETTINGS, &dm ) ){
        DebugMsg( _T("EnumDisplaySettings(\"%s\") failed:%d\r\n" ), d.DeviceName, GetLastError() );
        return FALSE;
    }

	if( dm.dmDisplayOrientation == dmOrientation ) return TRUE;
    w = dm.dmPelsHeight;
    dm.dmPelsHeight = dm.dmPelsWidth;
    dm.dmPelsWidth = w;

    dm.dmDisplayOrientation = dmOrientation;

    r = ChangeDisplaySettingsEx( d.DeviceName, &dm, NULL, CDS_UPDATEREGISTRY, NULL );
    if( r != DISP_CHANGE_SUCCESSFUL ){
        DebugMsg( _T("ChangeDisplaySettingsEx failed:%d\r\n"), r );
        return FALSE;
    }
    return TRUE;
}
开发者ID:hasegawayosuke,项目名称:RotateDisplay,代码行数:34,代码来源:display.c


示例9: PlatformResizeGLContext

/**
 * Resize the GL context.
 */
void PlatformResizeGLContext( FPlatformOpenGLDevice* Device, FPlatformOpenGLContext* Context, uint32 SizeX, uint32 SizeY, bool bFullscreen, bool bWasFullscreen, GLenum BackBufferTarget, GLuint BackBufferResource)
{
	FScopeLock ScopeLock(Device->ContextUsageGuard);
{
	uint32 WindowStyle = WS_CAPTION | WS_SYSMENU;
	uint32 WindowStyleEx = 0;
	HWND InsertAfter = HWND_NOTOPMOST;

	if (bFullscreen)
	{
		// Get the monitor info from the window handle.
		HMONITOR hMonitor = MonitorFromWindow(Context->WindowHandle, MONITOR_DEFAULTTOPRIMARY);
		MONITORINFOEX MonitorInfo;
		memset(&MonitorInfo, 0, sizeof(MONITORINFOEX));
		MonitorInfo.cbSize = sizeof(MONITORINFOEX);
		GetMonitorInfo(hMonitor, &MonitorInfo);

		DEVMODE Mode;
		Mode.dmSize = sizeof(DEVMODE);
		Mode.dmBitsPerPel = 32;
		Mode.dmPelsWidth = SizeX;
		Mode.dmPelsHeight = SizeY;
		Mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

		// Turn on fullscreen mode for the current monitor
		ChangeDisplaySettingsEx(MonitorInfo.szDevice, &Mode, NULL, CDS_FULLSCREEN, NULL);

		WindowStyle = WS_POPUP;
		WindowStyleEx = WS_EX_APPWINDOW | WS_EX_TOPMOST;
		InsertAfter = HWND_TOPMOST;
	}
	else if (bWasFullscreen)
	{
		ChangeDisplaySettings(NULL, 0);
	}

	//SetWindowLong(Context->WindowHandle, GWL_STYLE, WindowStyle);
	//SetWindowLong(Context->WindowHandle, GWL_EXSTYLE, WindowStyleEx);

		{
			FScopeContext ScopeContext(Context);

			if (Context->ViewportFramebuffer == 0)
			{
				glGenFramebuffers(1, &Context->ViewportFramebuffer);
			}
			glBindFramebuffer(GL_FRAMEBUFFER, Context->ViewportFramebuffer);
			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, BackBufferTarget, BackBufferResource, 0);
#if UE_BUILD_DEBUG
			glReadBuffer(GL_COLOR_ATTACHMENT0);
			glDrawBuffer(GL_COLOR_ATTACHMENT0);
#endif
			FOpenGL::CheckFrameBuffer();

			glViewport(0, 0, SizeX, SizeY);
			static GLfloat ZeroColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
			glClearBufferfv(GL_COLOR, 0, ZeroColor );
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:63,代码来源:OpenGLWindows.cpp


示例10: defined

void AppSetup::init()
{
#if defined(USES_LINUX)
	#error TODO
#elif defined(USES_WINDOWS8_METRO)
	// no way to change the resolution
#else
	// http://www.gamedev.net/topic/602791-c-change-screen-resolution/
	// http://www.codeproject.com/Articles/15072/Programmatically-change-display-resolution
	if (m_inf.changeDesktopResolution)
	{
		DEVMODE devMode;
		memset(&devMode, 0, sizeof(devMode));

		EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devMode);
		devMode.dmPelsWidth = m_inf.windowSize.width();
		devMode.dmPelsHeight = m_inf.windowSize.height();
		LONG res = ChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_FULLSCREEN, NULL);
		Assert(res == DISP_CHANGE_SUCCESSFUL);
		SendMessage(HWND_BROADCAST, WM_DISPLAYCHANGE, (WPARAM)32, MAKELPARAM(m_inf.windowSize.width(), m_inf.windowSize.height()));
	}
#endif

#if defined(USES_WINDOWS_OPENGL) || defined(USES_LINUX)
	m_openGL = new OpenGL(m_inf.windowTitle.c_str(), m_inf.windowSize, m_inf.isFullscreen, m_inf.automaticFitToWindowSize);
#else
	this->onResizeWindow(this->getWindowRealSize());
#endif

	Font::setDefaultFont(new Font(m_inf.defaultFontImgPath.c_str(), 1.f, 12));
	//this->set2DMode();
}
开发者ID:Arzar,项目名称:volatile-dove-engine,代码行数:32,代码来源:AppSetup.cpp


示例11: ChangeScreenResolution

boolean ChangeScreenResolution (int screenNumber, int width, int height, int bitsPerPixel, int fps)	// Change The Screen Resolution
{
  DEVMODE dmScreenSettings; // Device mode structure

  // Clear structure:
  memset (&dmScreenSettings, 0, sizeof (DEVMODE));
  dmScreenSettings.dmSize		= sizeof (DEVMODE);
  dmScreenSettings.dmDriverExtra	= 0;

  // Query current display settings and init struct with them:
  EnumDisplaySettings(PsychGetDisplayDeviceName(screenNumber), ENUM_CURRENT_SETTINGS, &dmScreenSettings);

  // Override current settings with the requested settings, if any:
  if (width>0)  dmScreenSettings.dmPelsWidth  = width;  // Select Screen Width
  if (height>0) dmScreenSettings.dmPelsHeight = height; // Select Screen Height
  if (bitsPerPixel>0) dmScreenSettings.dmBitsPerPel = bitsPerPixel; // Select Bits Per Pixel
  if (fps>0) dmScreenSettings.dmDisplayFrequency = fps; // Select display refresh rate in Hz
  
  // All provided values should be honored: We need to spec the refresh explicitely,
  // because otherwise the system will select the lowest fps for a given display mode.
  dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;

  // Perform the change:
  if (ChangeDisplaySettingsEx(PsychGetDisplayDeviceName(screenNumber), &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL) {
    return(FALSE);	// Display Change Failed, Return False
  }

  // Display Change Was Successful, Return True
  return(TRUE);
}
开发者ID:BackupTheBerlios,项目名称:osxptb-svn,代码行数:30,代码来源:PsychWindowGlue.c


示例12: ChangeDisplaySettingsEx

LONG CMirageManager::CommitDisplayChanges(DEVMODE* pdm, DISPLAY_DEVICE& deviceInfo)
{
	if (pdm)
	{
		LONG code = ChangeDisplaySettingsEx(deviceInfo.DeviceName, pdm, NULL, CDS_UPDATEREGISTRY, NULL);
		if (code < 0){return code;}
		code = ChangeDisplaySettingsEx(deviceInfo.DeviceName, pdm, NULL, 0, NULL);
		if (code < 0){return code;}
	}
	else
	{
		LONG code = ChangeDisplaySettingsEx(deviceInfo.DeviceName, NULL, NULL, 0, NULL);
		if (code < 0){return code;}
	}
	return ERROR_SUCCESS;
}
开发者ID:AsherBond,项目名称:DimSim,代码行数:16,代码来源:MirageManager.cpp


示例13: ChangeDisplaySettingsHook

LONG WINAPI ChangeDisplaySettingsHook(LPDEVMODEA lpDevMode, DWORD dwFlags)
{
	DWORD pCaller;
	__asm {mov eax, [ebp+0x4]}
	__asm {mov pCaller, eax}
	fprintf(logFile, "* ChangeDisplaySettings: %x, caller: %x\n", dwFlags, pCaller);
	fprintf(logFile, "hWnd: %x\n", *g_hWnd);
	fprintf(logFile, "hRenderWnd: %x\n", *g_hRenderWnd);
	fprintf(logFile, "GetForegroundWindow: %x\n", GetForegroundWindow());

	HWND hWnd = *g_hRenderWnd;
	char sWindowCaption[64];
	sWindowCaption[0] = 0;
	GetWindowText(hWnd, sWindowCaption, 64);

	fprintf(logFile, "Window caption: %s\n", sWindowCaption);
	
	HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
	
	fprintf(logFile, "hMonitor: %x\n", hMonitor);
	MONITORINFOEX stMonitorInfo;
	memset(&stMonitorInfo, 0, sizeof(MONITORINFOEX));
	stMonitorInfo.cbSize = sizeof(MONITORINFOEX);
	if(GetMonitorInfo(hMonitor, &stMonitorInfo))
	{
		fprintf(logFile, "Got monitor info\n");
		fprintf(logFile, "Device: %s\n", stMonitorInfo.szDevice);
	}
	else
	{
		fprintf(logFile, "MONITORINFO is NULL\n");
	}
	fflush(logFile);
	return ChangeDisplaySettingsEx(NULL, lpDevMode, NULL, dwFlags, NULL);
}
开发者ID:HellSinker,项目名称:nwncx,代码行数:35,代码来源:gui.cpp


示例14: EnumDisplaySettings

void triebWerk::CWindow::ChangeWindowSettings(const bool a_IsFullscreen, const unsigned short a_ScreenWidth, const unsigned short a_ScreenHeight)
{
	//Set new values
	m_IsFullscreen = a_IsFullscreen;
	m_Width = a_ScreenWidth;
	m_Height = a_ScreenHeight;

	//Set window rect
	RECT windowRectangle = { 0, 0, a_ScreenWidth ,a_ScreenHeight };

	DEVMODE dmScreenSettings;
	EnumDisplaySettings(NULL, 0, &dmScreenSettings);
	dmScreenSettings.dmSize = sizeof(dmScreenSettings);

	//If Fullscreen set target resolution if not set "normal" resolution
	if (a_IsFullscreen)
	{
		dmScreenSettings.dmPelsWidth = a_ScreenWidth;
		dmScreenSettings.dmPelsHeight = a_ScreenHeight;
	}
	else
	{
		dmScreenSettings.dmPelsWidth = static_cast<DWORD>(m_DefaultWidth);
		dmScreenSettings.dmPelsHeight = static_cast<DWORD>(m_DefaultHeight);
	}
	dmScreenSettings.dmBitsPerPel = 32;
	dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

	long error = ChangeDisplaySettingsEx(NULL, &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL);
	if (error != DISP_CHANGE_SUCCESSFUL)
	{
		//Make error
	}

	//Set the style for fullscreen or window
	if(a_IsFullscreen)
		SetWindowLongPtr(m_WindowHandle, GWL_STYLE, WindowStyleFullscreen);
	else
		SetWindowLongPtr(m_WindowHandle, GWL_STYLE, WindowStyleWindowed);

	//If window calculate correct client space
	if (!a_IsFullscreen)
		AdjustWindowRect(&windowRectangle, WindowStyleWindowed, FALSE);

	//Resize the window and draw it new
	SetWindowPos(m_WindowHandle, NULL, 0, 0, windowRectangle.right - windowRectangle.left, windowRectangle.bottom - windowRectangle.top, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_SHOWWINDOW);

	//Sadly the ShowCursor parameter is a incrementing bool  
	//Disable Cursor if Fullscreen enable if window
	if (m_ShowCursor == true && a_IsFullscreen)
	{
		ShowCursor(false);
		m_ShowCursor = false;
	}
	else if(m_ShowCursor == false && !a_IsFullscreen)
	{
		ShowCursor(true);
		m_ShowCursor = true;
	}
}
开发者ID:ManuelHaertl,项目名称:triebWerk,代码行数:60,代码来源:CWindow.cpp


示例15: memset

unsigned short CScreenOrientation::GetScreenSetting() {
#ifdef UNDER_CE
    DEVMODE devMode;
    memset(&devMode, 0, sizeof(devMode));
    devMode.dmSize=sizeof(devMode);
    devMode.dmFields = DM_DISPLAYORIENTATION;
    if(DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_TEST, NULL)) {
        return devMode.dmDisplayOrientation;
    }
#elif defined(KOBO)
    
    char szLine[100] = {};
    if(File::ReadString("/sys/class/graphics/fb0/rotate", szLine, sizeof(szLine))) {
        int tmp = strtol(szLine, nullptr, 10);
        switch(tmp) {
            case 0: return static_cast<short>(DisplayOrientation_t::LANDSCAPE);
            case 1: return static_cast<short>(DisplayOrientation_t::REVERSE_PORTRAIT);
            case 2: return static_cast<short>(DisplayOrientation_t::REVERSE_LANDSCAPE);
            case 3: return static_cast<short>(DisplayOrientation_t::PORTRAIT);
            default: return static_cast<short>(DisplayOrientation_t::DEFAULT);
        }
    }
#endif
    return -1;
}
开发者ID:acasadoalonso,项目名称:LK8000,代码行数:25,代码来源:CScreenOrientation.cpp


示例16: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	int deviceIndex=0;
	int result;
	DWORD bpp=16;

	do
	{
		PDISPLAY_DEVICE displayDevice = new DISPLAY_DEVICE();
		displayDevice->cb = sizeof(DISPLAY_DEVICE);

		result = EnumDisplayDevices(NULL, 
			deviceIndex++, displayDevice, 0);
		if (displayDevice->StateFlags & DISPLAY_DEVICE_ACTIVE)
		{
			PDISPLAY_DEVICE monitor = new DISPLAY_DEVICE();
			monitor->cb = sizeof(DISPLAY_DEVICE);

			EnumDisplayDevices(displayDevice->DeviceName, 
				0, monitor, 0);
			
			PDEVMODE dm = new DEVMODE();
			
			if ( EnumDisplaySettings(displayDevice->DeviceName,
				ENUM_CURRENT_SETTINGS, dm) )
			{
				dm->dmBitsPerPel=(DWORD)bpp;
				ChangeDisplaySettingsEx(displayDevice->DeviceName, dm,  \
                                     NULL, (CDS_GLOBAL | CDS_UPDATEREGISTRY | CDS_RESET), NULL);
			}
		}
	} while (result);
	return 0;
}
开发者ID:pysysops,项目名称:setbpp,代码行数:34,代码来源:setbpp.cpp


示例17: OS_GetDesktopRotation

///////////////////////////////////////////////////////////////////////////////
//	OS_GetDesktopRotation()
//
//	Gets the current orientation of the Desktop.  The return value is degrees
//	clockwise relative to 0 degrees orientation.
//
//	Arguments:
//		None.
//
//	Returns:
//		AU_ROTATE_0		0 degrees
//		AU_ROTATE_90	90 degrees
//		AU_ROTATE_180	180 degrees
//		AU_ROTATE_270	270 degrees
//
///////////////////////////////////////////////////////////////////////////////
int OS_GetDesktopRotation()
{
	DEVMODE DevMode;
	int CurrentAngle;
	int retval; 

	// Get the current rotation angle.
	memset(&DevMode, 0, sizeof (DevMode));
	DevMode.dmSize   = sizeof (DevMode);
	DevMode.dmFields = DM_DISPLAYORIENTATION;

	if (DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(NULL, &DevMode, NULL, CDS_TEST, NULL))
	{
		CurrentAngle = DevMode.dmDisplayOrientation;
	}
	else
	{ 
		CurrentAngle = -1;
	}

	// Only angle 270 is different in windows.
	if (CurrentAngle == DMDO_270)
		retval = AU_ROTATE_270;
	else
		retval = CurrentAngle;


	return retval;
}
开发者ID:xuweiqiang,项目名称:LibVRPresent,代码行数:45,代码来源:os_api.cpp


示例18: wf_mirror_driver_update

BOOL wf_mirror_driver_update(wfInfo* context, int unload)
{
	HDC dc;
	BOOL status;
	DWORD* extHdr;
	WORD drvExtraSaved;
	DEVMODE* deviceMode;
	LONG disp_change_status;
	DWORD dmf_devmodewext_magic_sig = 0xDF20C0DE;
	
	if (!unload)
	{
		/*
		 * Will have to come back to this for supporting non primary displays and multimonitor setups
		 */
		dc = GetDC(NULL);
		context->width = GetDeviceCaps(dc, HORZRES);
		context->height = GetDeviceCaps(dc, VERTRES);
		context->bitsPerPixel = GetDeviceCaps(dc, BITSPIXEL);
		ReleaseDC(NULL, dc);
	}
	else
	{
		context->width = 0;
		context->height = 0;
		context->bitsPerPixel = 0;
	}
	
	deviceMode = (DEVMODE*) malloc(sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX);
	deviceMode->dmDriverExtra = 2 * sizeof(DWORD);

	extHdr = (DWORD*)((BYTE*) &deviceMode + sizeof(DEVMODE)); 
	extHdr[0] = dmf_devmodewext_magic_sig;
	extHdr[1] = 0;

	drvExtraSaved = deviceMode->dmDriverExtra;
	memset(deviceMode, 0, sizeof(DEVMODE) + EXT_DEVMODE_SIZE_MAX);
	deviceMode->dmSize = sizeof(DEVMODE);
	deviceMode->dmDriverExtra = drvExtraSaved;

	deviceMode->dmPelsWidth = context->width;
	deviceMode->dmPelsHeight = context->height;
	deviceMode->dmBitsPerPel = context->bitsPerPixel;
	deviceMode->dmPosition.x = 0;
	deviceMode->dmPosition.y = 0;

	deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;

	_tcsncpy_s(deviceMode->dmDeviceName, 32, context->deviceName, _tcslen(context->deviceName));

	disp_change_status = ChangeDisplaySettingsEx(context->deviceName, deviceMode, NULL, CDS_UPDATEREGISTRY, NULL);

	status = (disp_change_status == DISP_CHANGE_SUCCESSFUL) ? TRUE : FALSE;

	if (!status)
		wf_mirror_driver_print_display_change_status(disp_change_status);
		
	return status;
}
开发者ID:woelfl-tw,项目名称:FreeRDP,代码行数:59,代码来源:wf_mirage.c


示例19: ZeroMemory

		//==============================================================================
		// フルスクリーンとウインドウモード切り替え
		//------------------------------------------------------------------------------
		void window::FlipWindowMode(void)
		{

			//==============================================================
			// DirectXの機能を使っていないので健康的
			//==============================================================

			if (!_bWindowMode)
			{
				DEVMODE devMod;
				ZeroMemory(&devMod, sizeof(devMod));
				devMod.dmSize = sizeof(devMod);
				devMod.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS;
				devMod.dmPelsWidth = GetSystemMetrics(SM_CXSCREEN);
				devMod.dmPelsHeight = GetSystemMetrics(SM_CYSCREEN);
				devMod.dmBitsPerPel = 32;
				devMod.dmDisplayFrequency = 60;
				devMod.dmDisplayFlags = 0;

				int hr = ChangeDisplaySettingsEx(NULL, &devMod, NULL, CDS_TEST | CDS_FULLSCREEN, NULL);

				if (hr == DISP_CHANGE_SUCCESSFUL)
				{
					ChangeDisplaySettingsEx(NULL, &devMod, NULL, CDS_FULLSCREEN, NULL);
				}
				else
				{
					_bWindowMode = false;
					return;
				}

				SetWindowLong(_hWnd, GWL_STYLE, GetWindowLong(_hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME));
				SetWindowLong(_hWnd, GWL_EXSTYLE, GetWindowLong(_hWnd, GWL_EXSTYLE) & ~(WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE));
				SetWindowPos(_hWnd, HWND_TOPMOST, 0, 0, devMod.dmPelsWidth, devMod.dmPelsHeight, SWP_SHOWWINDOW);
				_bWindowMode = true;
			}
			// Window mode
			else
			{
				ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL);
				SetWindowLong(_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX));
				SetWindowLong(_hWnd, GWL_EXSTYLE, GetWindowLong(_hWnd, GWL_EXSTYLE) | (WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE));
				SetWindowPos(_hWnd, HWND_NOTOPMOST, 0, 0, _width, _height, SWP_SHOWWINDOW);
				_bWindowMode = false;
			}
		}
开发者ID:YasuakiYamashita,项目名称:MozLib,代码行数:49,代码来源:mozWindow.cpp


示例20: GLW_ChangeDislaySettingsIfNeeded

/*
===================
GLW_ChangeDislaySettingsIfNeeded

Optionally ChangeDisplaySettings to get a different fullscreen resolution.
Default uses the full desktop resolution.
===================
*/
static bool GLW_ChangeDislaySettingsIfNeeded( glimpParms_t parms ) {
    // If we had previously changed the display settings on a different monitor,
    // go back to standard.
    if ( win32.cdsFullscreen != 0 && win32.cdsFullscreen != parms.fullScreen ) {
        win32.cdsFullscreen = 0;
        ChangeDisplaySettings( 0, 0 );
        Sys_Sleep( 1000 ); // Give the driver some time to think about this change
    }

    // 0 is dragable mode on desktop, -1 is borderless window on desktop
    if ( parms.fullScreen <= 0 ) {
        return true;
    }

    // if we are already in the right resolution, don't do a ChangeDisplaySettings
    int x, y, width, height, displayHz;

    if ( !GetDisplayCoordinates( parms.fullScreen - 1, x, y, width, height, displayHz ) ) {
        return false;
    }
    if ( width == parms.width && height == parms.height && ( displayHz == parms.displayHz || parms.displayHz == 0 ) ) {
        return true;
    }

    DEVMODE dm = {};

    dm.dmSize = sizeof( dm );

    dm.dmPelsWidth  = parms.width;
    dm.dmPelsHeight = parms.height;
    dm.dmBitsPerPel = 32;
    dm.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
    if ( parms.displayHz != 0 ) {
        dm.dmDisplayFrequency = parms.displayHz;
        dm.dmFields |= DM_DISPLAYFREQUENCY;
    }

    common->Printf( "...calling CDS: " );

    const char * const deviceName = GetDisplayName( parms.fullScreen - 1 );

    int		cdsRet;
    if ( ( cdsRet = ChangeDisplaySettingsEx(
                        deviceName,
                        &dm,
                        NULL,
                        CDS_FULLSCREEN,
                        NULL) ) == DISP_CHANGE_SUCCESSFUL ) {
        common->Printf( "ok\n" );
        win32.cdsFullscreen = parms.fullScreen;
        return true;
    }

    common->Printf( "^3failed^0, " );
    PrintCDSError( cdsRet );
    return false;
}
开发者ID:neilogd,项目名称:DOOM-3-BFG,代码行数:65,代码来源:win_glimp.cpp



注:本文中的ChangeDisplaySettingsEx函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ChangeServiceConfig函数代码示例发布时间:2022-05-30
下一篇:
C++ ChangeDisplaySettings函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap