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. tp3中子查询 逻辑条件是or

    直接用写sql最快 $map['_string'] = 'status=1 AND score>10'; //子查询条件字段不同 $condition['platform'] = 'swap'; ...

  2. [Algo] 281. Remove Spaces

    Given a string, remove all leading/trailing/duplicated empty spaces. Assumptions: The given string i ...

  3. PAT甲级——1019 General Palindromic Number

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  4. Django线上部署实战教程之Nginx+Gunicorn+Django篇

    #############################################   推荐 nginx supervisor gunicorn  配置简单,运维方便. Nginx (engi ...

  5. F5 BIG-IP之一前期随笔(应用交付网络产品)

    ADN:应用交付网络 TMOS:  Traffic  managment  operation  system  (流量管理系统) 一个实时的全应用代理流量管理操作系统             PVA ...

  6. made his acquaintance|adequate|advisable|announce|contrived to|made up|toss|considering that

    PHRASE 与(某人)初次相识;结识(某人)When you make someone's acquaintance, you meet them for the first time and ge ...

  7. C语言返回值

    C语言函数在结束的时候可以用一个数字表示运行的结果,这个数字就叫做函数的返回值. 主函数应该有一个返回值.如果这个返回值是0就表示程序希望计算机认为它正常结束,如果不是0就表示程序希望计算机认为它是出 ...

  8. 第一次作业:使用java实现word count

    github项目地址: https://github.com/changrui520/homework 作业要求: 可执行程序命名为:wc.exe. 该程序处理用户需求的模式为:wc.exe [par ...

  9. MSSS攝影大賽計劃書(第三版)

    比賽內容:對香港的城市風景以及自然風光的攝影 預期成果: 提升同學對香港的認識,鼓勵學生走出大學學園去瞭解香港,同時豐富會員的課餘活動,培養同學的興趣愛好 比賽時間:4月1-15日 最後作品提交時間: ...

  10. Qt QString 与 const char* 类型的转换

    QString DATA; std::string str = DATA.toStdString(); const char* ch = str.c_str();