#include<windows.h>
have already added, so why the GCC-mingw32 Compiler reported that 'GetConsoleWindow' was not declared in this scope
?
Here's my code:
#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;
}
Thanks. ^^
From msdn:
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later.
So you can try to replace
#include<windows.h>
with
#define _WIN32_WINNT 0x0500
#include<windows.h>
Or include SDKDDKVer.h
from Windows SDK:
Including SDKDDKVer.h defines the highest available Windows platform.
The documentation says:
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later.
I suspect that you did not do that.
You need to define the conditional before you include windows.h. Note that version 0x0500 corresponds to Windows 2000 so in the unlikely event that you want to support Windows NT4 or earlier, or Windows 9x, you'll need to switch to using run-time linking instead.
Or, if you get errors saying that it is redefined, you can use this :
#if _WIN32_WINNT < 0x0500
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With