Borland C ++ Builder FAQ
The content The last update: 12/12/2008

The size of the screen

The author (): kenai, OlegGG, trainer
The initial link: - - -

How to learn height and width of the screen in pixels?
For this purpose it is possible to use global object Screen, thus:
  Screen-> Width - width;
  Screen-> Height - height.


How to replace screen resolution?
DEVMODE dm; 
dm.dmSize = sizeof (DEVMODE); 
int index = 0; 
while (EnumDisplaySettings (NULL, index, &dm)) 
{ 
  if (dm.dmPelsWidth == 800 && dm.dmPelsHeight == 600) 
  { 
    dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; 
    LONG result = ChangeDisplaySettings (&dm, CDS_TEST); 
    if (result == DISP_CHANGE_SUCCESSFUL) 
    { 
      ChangeDisplaySettings (&dm, 0); 
      break; 
    }
    else if (result == DISP_CHANGE_RESTART) 
    { 
      ShowMessage ("reboot" Is required); 
      break; 
    }
    else 
    { 
      ShowMessage ("Setting is not supported by the monitor"); 
      break; 
    }
  }
  index ++; 
}

How to learn the size of work area of the screen?
Comment: Work area - the part of the screen which is not closed by a task bar
TRect rect; 
if (SystemParametersInfo (SPI_GETWORKAREA,0,&rect,0)) { 
   //received the size of work area 
   ShowMessage ("WorkArea size is" +AnsiString (rect. Width ()) + "x" +AnsiString (rect. Height ())); 
} else { 
   //it was not possible to receive the size of work area 
   ShowMessage ("GetWorkArea failed"); 
}