Thread: Getting the screen resolution

  1. #1
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154

    Question Getting the screen resolution

    Is there a function that gets the resolution of the screen?


  2. #2

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Or
    Code:
    #include <stdio.h>
    #include <windows.h>
    
    int main(int argc, char *argv[]){
        DEVMODE res;
        EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&res);
        printf("The screen resolution is %dx%d and %d bit per pixel\n",res.dmPelsWidth,res.dmPelsHeight,res.dmBitsPerPel);
        return 0;
    }
    More info at...

    //EDIT:
    Quote Originally Posted by Codeplug
    GetSystemMetrics(SM_CXSCREEN | SM_CXSCREEN);
    This function parameter isn't a flag, therefore you can't combine them (although you wrote twice SM_CXSCREEN).
    Should be
    Code:
    int height = GetSystemMetrics(SM_CYSCREEN);
    int width =GetSystemMetrics(SM_CXSCREEN);
    Last edited by xErath; 10-26-2004 at 08:51 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ubuntu screen resolution
    By lruc in forum Tech Board
    Replies: 13
    Last Post: 11-27-2008, 05:03 PM
  2. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  3. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  4. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  5. Screen Resolution
    By C_Coder in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 12-21-2001, 08:01 PM