SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 出错。不同系统或者不同版本VS

来源:互联网 发布:mysql count 性能 编辑:程序博客网 时间:2024/05/15 04:44

最新看到的是百度上的解答:

http://hi.baidu.com/vc_net/item/b8c5f761f70b9290c4d2494b
另外MSDN的介绍

typedef struct tagNONCLIENTMETRICS { UINT cbSize; int iBorderWidth; int iScrollWidth; int iScrollHeight; int iCaptionWidth; int iCaptionHeight; LOGFONT lfCaptionFont; int iSmCaptionWidth; int iSmCaptionHeight; LOGFONT lfSmCaptionFont; int iMenuWidth; int iMenuHeight; LOGFONT lfMenuFont; LOGFONT lfStatusFont; LOGFONT lfMessageFont;#if (WINVER >= 0x0600) int iPaddedBorderWidth;#endif } NONCLIENTMETRICS, *LPNONCLIENTMETRICS;


应该这个样子:
C/C++ code
nm.cbSize = sizeof (NONCLIENTMETRICS) - sizeof(nm.iPaddedBorderWidth);
// 这个是高版本.通常所说的VISTA版本 WINVEE >= 0x0600nm.cbSize = sizeof (NONCLIENTMETRICS) ; // 这个是低版本,通常所说的0x0501


或者在stdafx.h加入

#define WINVER 0x0501 // 关键:将此值更改为相应的值,以适用于 Windows 的其他版本。#define _WIN32_WINNT 0x0600 // 响应鼠标滚轮需要#define _WIN32_IE 0x0600 /*IE 6.0*/


 

所以在C/C++中使用过程具体如下:

NONCLIENTMETRICS nm;nm.cbSize = sizeof (NONCLIENTMETRICS);// Vista版本要减去  sizeof(nm.iPaddedBorderWidth);VERIFY (SystemParametersInfo (SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0)); 



 

原创粉丝点击