本文整理汇总了C++中ChangeDisplaySettingsEx函数的典型用法代码示例。如果您正苦于以下问题:C++ ChangeDisplaySettingsEx函数的具体用法?C++ ChangeDisplaySettingsEx怎么用?C++ ChangeDisplaySettingsEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ChangeDisplaySettingsEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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
}
示例5: 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;
}
示例6: 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;
}
示例7: _glfwSetVideoMode
int _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* mode)
{
GLFWvidmode current;
const GLFWvidmode* best;
DEVMODE dm;
best = _glfwChooseVideoMode(monitor, mode);
_glfwPlatformGetVideoMode(monitor, ¤t);
if (_glfwCompareVideoModes(¤t, 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;
}
示例8: 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(¤t_mon, 0, sizeof(current_mon));
current_mon.cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(g_last_hm, (MONITORINFO*)¤t_mon);
ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
g_restore_desktop = false;
}
g_inited = false;
}
示例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 );
}
}
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}