industrialNETworXnetx

| 27.03.2006 | 16:14 | 0 replies

display modi

It is possible to change the rotation angle at runtime via application or at compile/startup time by replacing the registry key "Rotation" under [HKEY_LOCAL_MACHINE\Drivers\Display\netX] as mentioned in the netX Windows CE BSP documentation.

The following code demonstrates screen rotation at runtime.

  DEVMODE tDevMode = {0};

tDevMode.dmSize = sizeof(DEVMODE);
tDevMode.dmFields = DM_DISPLAYQUERYORIENTATION;

LONG lQuerySuccess = ChangeDisplaySettingsEx(NULL, &tDevMode, NULL, CDS_TEST, NULL);

if(ERROR_SUCCESS != lQuerySuccess)
{
printf("DM_DISPLAYQUERYORIENTATION failed! (LastError=%u)\n", GetLastError());
} else
{
unsigned long ulSupportedModes = tDevMode.dmDisplayOrientation;

printf("Screen Rotations supported: \n");
printf(" - 0°\n");
if(ulSupportedModes & DMDO_90)
printf(" - 90°\n");
if(ulSupportedModes & DMDO_180)
printf(" - 180°\n");
if(ulSupportedModes & DMDO_270)
printf(" - 270°\n");

tDevMode.dmFields = DM_DISPLAYORIENTATION;
lQuerySuccess = ChangeDisplaySettingsEx(NULL, &tDevMode, NULL, CDS_TEST, NULL);

ASSERT(ERROR_SUCCESS == lQuerySuccess);

DEVMODE tNewMode = {0};
tNewMode.dmSize = sizeof(DEVMODE);
tNewMode.dmFields = DM_DISPLAYORIENTATION;
tNewMode.dmDisplayOrientation = tDevMode.dmDisplayOrientation;

do
{
switch(tNewMode.dmDisplayOrientation)
{
case DMDO_0:
tNewMode.dmDisplayOrientation = DMDO_90;
break;

case DMDO_90:
tNewMode.dmDisplayOrientation = DMDO_180;
break;

case DMDO_180:
tNewMode.dmDisplayOrientation = DMDO_270;
break;

case DMDO_270:
tNewMode.dmDisplayOrientation = DMDO_0;
break;
}

if( (tNewMode.dmDisplayOrientation & ulSupportedModes) ||
(tNewMode.dmDisplayOrientation == DMDO_0) )
{
//switch mode if it is supported
LONG lRes = ChangeDisplaySettingsEx(NULL, &tNewMode, NULL, CDS_RESET, NULL);
Sleep(1000);
}
} while(tNewMode.dmDisplayOrientation != tDevMode.dmDisplayOrientation);

//switch back to start mode
ChangeDisplaySettingsEx(NULL, &tNewMode, NULL, CDS_RESET, NULL);
}

Login