с++ класс не содержит члена; аргумент несовместим с параметром
Пытался подправить ошибки самостоятельно, но пока что безуспешно
А вот, собственно, сами ошибки :
E0135 class "Practform::MyForm" не содержит члена "draw_wrapper"
E0167 аргумент типа "Practform::MyForm ^" несовместим с параметром типа "void *"
Сразу приведу полный(не совсем так..только необходимый) листинг программы.
Буду благодарен за помощь
таймер:
#pragma once
#ifndef TIMERHPP
#define TIMERHPP
#include <chrono>
#include <functional>
class Timer1 {
public:
void add(std::chrono::milliseconds delay,
std::function<void(void*)> callback,
void* user_data_ptr,
bool asynchronous = true);
};
#endif
#include "timer.h"
#include <thread>
Timer1::Timer1() {
}
void Timer1::add(std::chrono::milliseconds delay,
std::function<void(void*)> callback,
void* user_data_ptr,
bool asynchronous) {
if (asynchronous) {
std::thread([=]() {
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
callback(user_data_ptr);
}).detach();
}
else {
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
callback(user_data_ptr);
}
}
сама программа:
using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;
[STAThreadAttribute]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Practform::MyForm form;
Application::Run(% form);
}
class MyForm {
public:
void draw1();
static System::Void draw_wrapper(void* object) {
reinterpret_cast<MyForm*>(object)->draw1();
}
};
System::Void Practform::MyForm::draw1() {
// Timer1 timer;
int unit = 35;
int pW = pictureBox1->Width;
int pH = pictureBox1->Height;
Bitmap^ img = gcnew Bitmap(pW, pH);
Graphics^ g = Graphics::FromImage(img);
for (int i = 0; i < pW; i += unit)
g->DrawLine(Pens::LightGray, i, 0, i, pH);
for (int i = 0; i < pH; i += unit)
g->DrawLine(Pens::LightGray, 0, i, pW, i);
Pen^ BlackPen = gcnew Pen(Brushes::Black);
BlackPen->Width = 3.0F;
int mX = int(pW / 2 - pW / 2 % unit);
int mY = int(pH / 2 - pH / 2 % unit);
g->DrawLine(BlackPen, mX, 0, mX, pH);
g->DrawLine(BlackPen, 0, mY, pW, mY);
g->ScaleTransform(1, -1);
g->TranslateTransform((float)mX, -(float)mY);
float x1 = -7.5f, x2 = 7.5f, s = 0.2f;
float x = x1;
float y;
System::Collections::Generic::List<PointF>^ ponts = gcnew System::Collections::Generic::List<PointF>();
while (x < x2)
{
y = (double)fcnPtr(x);
ponts->Add(PointF(x * (double)unit, y * (double)unit));
x += s;
}
g->DrawLines(Pens::Green, ponts->ToArray());
delete g;
this->pictureBox1->Image = img;
}
System::Void Practform::MyForm::draw_Click(System::Object^ sender, System::EventArgs^ e)
{
Timer1 timer;
//MyForm MyFormobj;
timer.add(std::chrono::milliseconds(500), &MyForm::draw_wrapper, this);
}