"GetConsoleWindow"未在此范围内声明?
'GetConsoleWindow' was not declared in this scope?
#include<windows.h>
已经添加了,那么为什么GCC-mingw32编译器报告了'GetConsoleWindow' was not declared in this scope
?
这是我的代码:
#include<iostream>
#include<cmath>
#include<windows.h>
using namespace std;
#define PI 3.14
int main()
{
//Get a console handle
HWND myconsole = GetConsoleWindow();
//Get a handle to device context
HDC mydc = GetDC(myconsole);
int pixel =0;
//Choose any color
COLORREF COLOR= RGB(255,255,255);
//Draw pixels
for(double i = 0; i < PI * 4; i += 0.05)
{
SetPixel(mydc,pixel,(int)(50+25*cos(i)),COLOR);
pixel+=1;
}
ReleaseDC(myconsole, mydc);
cin.ignore();
return 0;
}
谢谢。^^
来自 msdn:
若要编译使用此函数的应用程序,请定义_WIN32_WINNT 作为0x0500或更晚。
所以你可以尝试更换
#include<windows.h>
跟
#define _WIN32_WINNT 0x0500
#include<windows.h>
或者包含来自 Windows SDK 的SDKDDKVer.h
:
包括SDKDDKVer.h定义了最高的可用Windows平台。
文档说:
若要编译使用此函数的应用程序,请将_WIN32_WINNT定义为 0x0500 或更高版本。
我怀疑你没有这样做。
在包含 windows.h 之前,您需要定义条件。请注意,版本 0x0500 对应于 Windows 2000,因此,在不太可能的情况下,如果您想支持 Windows NT4 或更早版本或 Windows 9x,则需要切换到使用运行时链接。
或者,如果您收到错误说它已重新定义,则可以使用以下命令:
#if _WIN32_WINNT < 0x0500
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
相关文章:
- 错误:未在此范围内声明'reverse'
- 错误:"imread"未在此范围内声明
- 我在范围内未声明的错误类有问题
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 在此范围内未声明错误"Clreol"
- 如何找到在本地范围内声明的变量的地址?
- 简化在 Pybind11 中为 C++ 模板类生成包装类:模板声明不能出现在块范围内
- NT状态未在此范围内声明
- 变量未在此范围内声明 数组线性搜索
- 包含文件中的 Typdef "未在此范围内声明"
- 'ClassName'和'ClassInstance'未在此范围内声明
- "ChaCha"尚未在此范围内使用Crypto++声明?
- C++ 中的类之间的数据重新循环 - 错误:'<class name>'未在此范围内声明
- 如何在类声明范围内使用“using space::function”