您的位置:首页 > 编程语言 > C语言/C++

c++ winform 不能调用获取屏幕分辨率函数GetSystemMetrics的问题

2014-01-15 23:39 375 查看
#include "windows.h"

#pragma comment(lib, "user32.lib")

int cx = GetSystemMetrics( SM_CXSCREEN );

int cy = GetSystemMetrics( SM_CYSCREEN );

参考MSDN资源如下:

I am trying to get the size of the button in Windows in my project using windows API GetSystemMetrics(SM_CXSIZE).

Whereas GetSystemMetrics(SM_CXSIZE) returns '36' in Windows 8 and I am able to adjust the tool bar window correctly. But it returns '22' in Windows Server 2012 and I am not able to adjust my tool bar properly.

A sample code snippet is:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")

int main()
{
printf("Value SM_CXSIZE: %d", GetSystemMetrics(SM_CXSIZE));
return 0;
}


Can you please suggest a way to accomplish this.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: