包含 Windows.h 和 wingdi.h 时出现"GradientFill was not declared in this scope"错误
"GradientFill was not declared in this scope" error when including windows.h and wingdi.h
以下是代码:
#include <windows.h>
#include <wingdi.h>
#include <tchar.h>
#include <string>
#include <iostream>
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) //handling the message; all cases should be in logical order
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc;
GRADIENT_RECT rc;
TRIVERTEX vertex[2] ;
//vertex settings...
hdc = BeginPaint(hwnd, &ps);
GradientFill(hdc, vertex, 2, &rc, 1, GRADIENT_FILL_RECT_V);
EndPaint(hwnd, &ps);
break;
}
}
}
我从title中得到消息,当我切换wingdi.h和windows.h时,我会从wingdi.h文件中得到大量错误。我使用代码块。
GradientFill的文档告诉您,哪个头声明了一个符号,哪个头要包括:
标题:WinGdi.h(包括Windows.h)
当GradientFill
在WinGdi.h中声明时,您应该只声明#include <Windows.h>
。
注意:如果这不能解决您的问题,您可能需要考虑选择另一个IDE。Code::众所周知,块是脆弱的,有很多问题,并且是错误默认值的弱点(例如ANSI/Codepage字符编码与Unicode)。Visual Studio Community 2015是一个功能齐全的IDE,可以免费使用。
相关文章:
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 类中的数组变量C++导致"was not declared in this scope"实现文件的一个函数中错误,但在构造函数中不会导致错误
- 如何解决"cout was not declared in this scope"错误?
- 为什么程序显示我"was not declared in this scope"?
- 为什么我会收到"getuid was not declared in that scope"错误?
- 即使包含 <time.h 后仍"‘CLOCK_PER_SEC’ was not declared in this scope"错误>
- 如何在链接器设置和搜索目录更改后修复" '::iswblank' has not been declared"
- 我正在接受"Error: string was not declared in this scope"
- C++ 我一直在"was not declared in this scope error"
- 明确声明时显示"DialogProc not declared"错误
- C++自定义分配器:const_pointer 'has not been declared'
- 将 .ui 文件导入 Qt5 C++时出错"was not declared in this scope"
- 编译 CPP 应用程序时出错。 "error: 'posix_memalign' was not declared in this scope"
- main.cpp中的错误:函数库中的函数"not declared in this scope",但实际上是
- "Error: 'dungeon_t' was not declared in this scope"但包含在标题中
- C++ 中的" Variable ' i ' was not declared in scope "是什么?
- "pointer was not declared in this scope"是什么意思
- 学习如何在遇到错误'variable not declared in scope'的 c++ 中使用指针
- "error: not declared in this scope?"是什么意思
- 宣布时的另一个'not declared in this scope'问题