API:

要取得屏幕大小,可以用下面几个函数:

# include <windows.h>
int cx = GetSystemMetrics( SM_CXFULLSCREEN );
int cy = GetSystemMetrics( SM_CYFULLSCREEN );

通过上边两个函数获取的是 显示屏幕的大小,但不包括任务栏等区域。

int  cx   =   GetSystemMetrics(   SM_CXSCREEN   );
int cy = GetSystemMetrics( SM_CYSCREEN );

这两个函数获取的是真正屏幕的大小。
MFC:

HDC hDC =  ::GetDC(HWND(NULL));               // 得到屏幕DC
int x = ::GetDeviceCaps(hDC,HORZRES); // 宽
int y = ::GetDeviceCaps(hDC,VERTRES); // 高
::ReleaseDC(HWND(NULL),hDC); // 释放DC

c++获取屏幕大小的更多相关文章

  1. js获取屏幕大小

    1.js获取屏幕大小 <html> <script> function a(){ document.write( "屏幕分辨率为:"+screen.widt ...

  2. 转:VC++获取屏幕大小第一篇 像素大小GetSystemMetrics

    VC++获取屏幕大小第一篇 像素大小 GetSystemMetrics>和<VC++获取屏幕大小第二篇物理大小GetDeviceCaps 上>和<VC++获取屏幕大小第三篇物理 ...

  3. wift - 使用UIScreen类获取屏幕大小尺寸

    UISreen类代表了屏幕,开发中一般用来获取屏幕相关的属性,例如获取屏幕的大小. 1 2 3 4 5 6 7 //获取屏幕大小 var screenBounds:CGRect = UIScreen. ...

  4. Android 获取屏幕大小和密度

    Android 获取屏幕大小和密度 DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay ...

  5. cocos2d-x JS 获取屏幕大小或中点

    以一张背景图为例: var HelloWorldLayer = cc.Layer.extend({ ctor:function () { this._super(); var bg = new cc. ...

  6. Android获取屏幕大小和设置无标题栏

    android获取屏幕大小非常常用,例如写个程序,如果要做成通用性很强的程序,适用屏幕很强,一般布局的时候都是根据屏幕的长宽来定义的,所以我把这个总结一下,方便日后忘记的时候查阅.还有就是有时候写程序 ...

  7. 绘制bitmap 全屏 安卓获取 屏幕大小

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 绘制bitmap 全屏 Rectf rectF = new RectF(0, 0, w, ...

  8. C#获取屏幕大小或任务栏大小

    C#获取屏幕大小或任务栏大小http://www.cnblogs.com/chlyzone/archive/2012/11/05/2754601.html

  9. [linux][c++]linux c++ 通过xcb库获取屏幕大小

    linux c++ 通过xcb库获取屏幕大小 #include <stdio.h> #include <xcb/xcb.h> /** clang++ main.cpp -o m ...

  10. Android获取屏幕大小

    本来想着如下方法就能得到了 Display display = getWindowManager().getDefaultDisplay(); Log.i("view", &quo ...

随机推荐

  1. java.lang.IllegalArgumentException: Cannot format given Object as a Date

    在进行日期转换的时候遇到了这个问题, 非常的恼火 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" ...

  2. MySQL_备份

    Mysql 的备份 前情了解与小试 三种级别的备份与恢复数据:​1.表级别备份:mysqldump [OPTIONS] database [tables]mysqldump -p密码 库名 表名 &g ...

  3. 字典 -> model

    1.使用KVC init(dict : [String : Any]) { super.init() setValuesForKeys(dict) } override func setValue(_ ...

  4. 如何使用 babel

    babel-cli 在项目内运行 babel-cli 配置.babelrc 配置.jshintrc Babel 用于将 ES6 的代码转化为 ES5,使得 ES6 可以在目前的浏览器环境下使用.学习使 ...

  5. RDS的xb文件恢复到本地mysql5.6版本数据库

    参考博客: https://blog.csdn.net/a18838964650/article/details/82800621  安装qpress软件 https://www.cnblogs.co ...

  6. Image.FromStream(ms) 提示参数无效

    说明ms有问题,首先确保有读到数据,这种情况是保存到库的时候出错的. 原来你可能是这样写的: MemoryStream stream = new MemoryStream();PictureBox1. ...

  7. Simple Random Sampling|representative sample|probability sampling|simple random sampling with replacement| simple random sampling without replacement|Random-Number Tables

    1.2 Simple Random Sampling Census, :全部信息 Sampling: 抽样方式: representative sample:有偏向,研究者选择自己觉得有代表性的sam ...

  8. Ubuntu 12.04 搭建TFTP服务器

    吐槽先:在Ubuntu上搭建TFTP服务器,网上搜到一堆资料,可惜基本都是部分能用,至于哪些部分能用还要自己摸索着试出来,郁闷之情仅次于找不到任何资料…… ---------------------- ...

  9. 77)PHP,将session数据写到不用的存储介质中

    首先我的siession数据可以写到:文件中    session数据区  或者数据库中, 那么怎么将文件中的session数据或者session数据区的数据写到  数据库中,,又或者任意挑选两个不同 ...

  10. [LC] 225. Implement Stack using Queues

    Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. po ...