簡體   English   中英

包括windows.h和wingdi.h時出現“在此范圍內未聲明GradientFill”錯誤

[英]“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;
        }
    }
}

我從標題中得到了消息,當我切換wingdi.h和windows.h時,我從wingdi.h文件中得到了很多錯誤。 我使用代碼塊。

GradientFill的文檔會告訴您,哪個標頭聲明一個符號以及要包含的標頭:

標題:WinGdi.h(包括Windows.h)

WinGdi.h中聲明GradientFill ,您僅應#include <Windows.h>


注意:如果這不能解決您的問題,則可能需要考慮選擇其他IDE。 眾所周知,Code :: Blocks很脆弱,存在很多問題,並且對錯誤的默認設置情有獨鍾(例如ANSI / Codepage字符編碼與Unicode)。 Visual Studio Community 2015是功能齊全的IDE,可以免費使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM