【发布时间】:2016-04-20 11:19:44
【问题描述】:
我试图让这段代码在我的应用程序窗口中画一个圆圈:
Draw Circle;
Circle.DrawCircle(hwnd, i*200+5, j*200+5, i*200+194, j*200+194, 7, (255, 0, 0));
我使用的类,叫做 Draw.cpp,看起来像这样
#include "Draw.h"
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <tchar.h>
#include <windows.h>
#include <vector>
using namespace std;
Draw::Draw()
{
}
void DrawCircle(HWND vhwind, int xPosTopLeft, int yPosTopLeft, int xPosBotRight, int yPosBotRight, int width, vector <int> rgb)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(vhwind, &ps);
HPEN hPenOld;
HPEN hLinePen = CreatePen(PS_DASH, width, RGB (rgb[0], rgb[2], rgb[2]));
hPenOld = (HPEN)SelectObject(hdc, hLinePen);
Arc(hdc, xPosTopLeft, yPosTopLeft, xPosBotRight, xPosBotRight, NULL, NULL, NULL, NULL);
SelectObject(hdc, hPenOld);
DeleteObject(hLinePen);
}
名为 Draw.h 的头文件如下所示:
#ifndef DRAW_H
#define DRAW_H
#include "Draw.h"
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <tchar.h>
#include <windows.h>
#include <vector>
using namespace std;
class Draw
{
public:
Draw();
void DrawCircle(HWND vhwind, int xPosTopLeft, int yPosTopLeft, int xPosBotRight, int yPosBotRight, int width, vector <int> rgb);
protected:
private:
};
#endif // DRAW_H
我认为这个问题与“HWND vhwind”有关。 错误消息说:“错误:没有匹配的函数调用'Draw :: DrawCircle(HWND__ *&,int,int,int,int,int,int)'” 谁能告诉我我做错了什么?
【问题讨论】:
-
错误信息有一个行号。它不指向您发布的任何代码。此外,您没有名为 DrwawCircle 的方法。
-
确保您已在 Draw.h 文件中声明了 DrawCircle() 函数。同样在 cpp 文件中,现在您将
void DrawCircle更改为void Draw::DrawCircle( -
您传递的参数类型与函数签名不匹配。