Screen Res

Started by
2 comments, last by Emagen 23 years, 8 months ago
Hi everybody- Does anyone know if there is a function or a procedure to get the current window resolution? For example, I have Windows98 at a resolution of 1600x1200 and I have a program that runs in a window mode at 800x600. I want to know how my program can know what the Windows98 resolution is. Thank everybody for your help.
Advertisement
Yes, there is a way, this is the way i do it

******************************************************
// The Part following goes in the header
//screen mode type
typedef struct
{
int width ;
int height ;
int bpp ;
} SCREEN_MODE ;

//to get the current screen mode
SCREEN_MODE SCREEN_get_current_resolution();


*********************************************************
// The Part Following will go in the *.cpp file
SCREEN_MODE SCREEN_get_current_resolution()
{
SCREEN_MODE result;
DEVMODE devmode ;

result.width = 0 ;
result.height = 0 ;
result.bpp = 0 ;
ZeroMemory( &devmode, sizeof(DEVMODE));
devmode.dmSize = sizeof(DEVMODE);
if( EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS , &devmode ) == TRUE )
{
result.width = devmode.dmPelsWidth ;
result.height = devmode.dmPelsHeight ;
result.bpp = devmode.dmBitsPerPel ;
}

return result ;
}


Hope this helps, The function return, Width height and Bits per Pixel/Colours.
42
Isn''t there a much simpler way to do this....some functoin like GetSystemMetrics or something....look it up on the msdn. Sorry I can''t provide any more info but I just can''t remember!

-blide
blide@mail.com
-blideblide@mail.com
    hres = GetSystemMetrics( SM_CXSCREEN );vres = GetSystemMetrics( SM_CYSCREEN );    


This topic is closed to new replies.

Advertisement