是否可以检测宽显示器? [英] Is it possible to detect a wide monitor?

查看:79
本文介绍了是否可以检测宽显示器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WinXP SP3,带有MingW的代码块,SDL.

我想知道是否有人可以检测计算机的屏幕宽度,例如#ifdef LAPTOP或类似的东西;我现在也知道一些较新的台式机的屏幕更宽.原因是,我希望爆炸可以理想地在所有计算机上显示.对于我的显示器,我使用"0.9 *适用于x的数字"来执行操作,但是当然,在宽屏(例如笔记本电脑或较新的显示器)上,它看起来像是一个侧面的椭圆形,尽管我从未使用过那些,所以我可能是错的.感谢您的所有回复! -B :)

编辑3-1-11:将0.8更改为0.9以上.

Hi, I use WinXP SP3, Codeblocks w/MingW, SDL.

I''m wondering if anyone knows if it is possible to detect how wide a computer''s screen is, such as #ifdef LAPTOP or something like that; I''m also aware of wider screens nowadays on some of the newer desktops. The reason is, I want my explosion to look round on all computers ideally. For my monitor I use "0.9 * the number that would be proper for x" to do things, but of course that would look like a sideways oval on wider screens like laptops or perhaps the newer monitors, though I''ve never used one of those yet so I could be wrong. Thanks for any and all replies! -B :)

edit 3-1-11: changed 0.8 to 0.9 above.

推荐答案

您不能使用#ifdef-在需要的地方会影响编译时的代码在运行时影响它.
使用 GetSystemMetrics [
You can''t use a #ifdef - that affects the code at compilation, where you need to affect it at run time.
Use GetSystemMetrics[^] - it gives all the info you will need.


这些天几乎所有的显示器都有正方形像素.也就是说,如果说在一个垂直厘米中有42个像素,那么在一个水平厘米中将有42个像素.因此,如果自然绘制,则圆形和正方形看起来正确(像素宽度=像素高度).
当然,以上答案对于找到显示器的整体尺寸是正确的.警告!当心多显示器设置.您需要注意区分任何特定显示器的大小和桌面的大小.找出要处理的对象并不容易.

祝你好运!
Almost all displays these days have square pixels. That is, if there are, say 42 pixels in one vertical cm, there will be 42 in one horizontal cm. So circles and squares look right if drawn naturally (width-in-pixels = height-in-pixels).
Of course, the answers above are correct for finding the overall size of the display. Warning! Beware of multi-monitor setups. You need to be careful to distinguish between the size of any particular monitor and the size of the desktop. Finding out which one you are dealing with is not alsways easy.

Good luck!


使用此代码:

Use this code:

DEVMODE dm;
ZeroMemory(&dm, sizeof(DEVMODE));
dm.dmSize = sizeof(DEVMODE);
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
{
   // Width and height (in pixel) of the monitor are:
   int width = dm.dmPelsWidth;
   int height = dm.dmPelsHeight;
}


这篇关于是否可以检测宽显示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆