Home > Back-end >  Cannot new GDI objects, to solve
Cannot new GDI objects, to solve

Time:09-20

 
H # include "Windows."
# include "gdiplus. H"
# include "iostream"
Using the namespace Gdiplus;
using namespace std;
Int main (void)
{
Cout<& lt;" 1 ";
Pen * myPen;
MyPen=new Pen (Color (255, 255, 0, 0), 3);
Cout<& lt;" 2 ";
return 0;
}

Cannot output 2, not new to the Pen object, and the program in the flash back, to solve!
Gdiplus library is link

This example is given according to the Windows written document, the line is a copy of the original sentence
https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-changes-in-the-programming-model-about

CodePudding user response:

You need use gdi + GdiplusStartup (& amp; GdiplusToken, & amp; GdiplusStartupInput, NULL);

CodePudding user response:

 # include "Windows. H" 
# include "gdiplus. H"
# include "iostream"
Using the namespace Gdiplus;
using namespace std;
# pragma comment (lib, "Gdiplus. Lib")
Int main (void)
{
The GdiplusStartupInput GdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup (& amp; GdiplusToken, & amp; GdiplusStartupInput, NULL);
Cout & lt; <"1";
Pen * myPen;
MyPen=new Pen (Color (255, 255, 0, 0), 3);
Cout & lt; <"2";
return 0;
}
  • Related