【问题标题】:'Gdiplus::Graphics' : no appropriate default constructor available\'Gdiplus::Graphics\' : 没有合适的默认构造函数可用
【发布时间】:2022-11-01 14:16:26
【问题描述】:
Not sure what I am doing wrong.. I have a very muddy idea of how Constructors should be formatted or structured, so any insights would help!


    Renderer.h
#pragma once

#include <afxwin.h>
#include <winapifamily.h>
#include <wtypes.h>

#include <gdiplus.h>

class Renderer
{
public:
Renderer();
~Renderer();


void Clear(Gdiplus::Color clearColor);

virtual void Free() = 0;
virtual void LoadFace(int index, char* path) = 0;
void InitFromHDC(HDC dc);
void Shutdown();

// Drawing surface
Gdiplus::Graphics _graphics;

受保护:

私人的:

bool _gdiplusActive;

};

渲染器.cpp

渲染器::渲染器() : _gdiplusActive(假) { // <-错误在这里 }

渲染器::~渲染器() {}

...


我尝试了许多添加变量的变体......但老实说,错误可能很明显,谁了解默认构造函数是什么。我不知道。

【问题讨论】:

    标签: constructor gdi+


    【解决方案1】:

    默认构造函数是不带参数的构造函数。

    你不能凭空创建 Gdiplus::Graphics,你需要给它一些可以绘制的东西:位图、窗口或设备上下文。

    以下是可用的构造函数列表: https://learn.microsoft.com/en-us/windows/win32/api/gdiplusgraphics/nf-gdiplusgraphics-graphics-graphics(constgraphics_)

    【讨论】:

      猜你喜欢
      • 2016-04-22
      • 2017-08-15
      • 1970-01-01
      • 1970-01-01
      • 2011-12-22
      • 2016-01-22
      • 2014-06-23
      • 1970-01-01
      • 2013-03-20
      相关资源
      最近更新 更多