Getting the screen resolution

This is a discussion on Getting the screen resolution within the Windows Programming forums, part of the Platform Specific Boards category; Is there a function that gets the resolution of the screen?...

  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
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662

  3. #3
    #include<xErath.h> xErath's Avatar
    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, 04:03 PM
  2. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 03:56 PM
  3. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 09: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, 07:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21