Archived

This topic is now archived and is closed to further replies.

Emagen

Screen Res

Recommended Posts

Emagen    122
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.

Share this post


Link to post
Share on other sites
nraiyani    122
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.

Share this post


Link to post
Share on other sites
blide    122
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
    
hres = GetSystemMetrics( SM_CXSCREEN );
vres = GetSystemMetrics( SM_CYSCREEN );


Share this post


Link to post
Share on other sites