I have written simple class with few public variables and public methods. But the problem is that i can't use global program function in my class method.
Unit1.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TTimer *Timer1;
void __fastcall FormMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y);
void __fastcall FormCreate(TObject *Sender);
void __fastcall Timer1Timer(TObject *Sender);
void __fastcall FormPaint(TObject *Sender);
private: // User declarations
public: // User declarations
void Valyti(int x1, int y1, int x2, int y2);
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
class button {
public :
int pr, g;//y
bool uzejes;
float left;//kiek islindes
int max;//kiek daugiausia islenda
int greitis;//kiek px/piesima
void Pradzia(int pradzia, int galas, int ilg, int speed);
void Progress(int X, int Y);
};
Unit1.cpp(only part of it, because it's quite long)
//---------------------------------------------------------------------------
void TForm1::Valyti(int x1, int y1, int x2, int y2)
{
TRect kv;
kv.left = x1;
kv.right = x2;
kv.top = y1;
kv.bottom = y2;
Form1->Canvas->BrushCopy(kv, fonas->Bitmap, kv, clBlack);
}
//---------------------------------------------------------------------------
void button::Pradzia(int pradzia, int galas, int ilg, int speed)
{
pr = pradzia;
g = galas;
left = 0;
max = ilg;
greitis = speed;
uzejes = 0;
}
void button::Progress(int X, int Y)
{
X -= 10;
bool dbr;//ar dbr uzejes
dbr = ((Y >= pr && Y <= g) && (X <= left));
if (uzejes)
{
if (!dbr)
{
//nustojo vaziuoti
uzejes = 0;
}
else
{
//toliau vaziuoja
if (left < max)
{
left += (float((max-left))/max*greitis);
if (left > max)
left = max;
}
}
}
else
{
if (dbr)
{
//pradejo vaziuoti
uzejes = 1;
}
else
{
//nera ant jo uzejusio, tikrinti ar vaziuoja atgal
if (left > 0)
{
int pradzioje = left;
left -= greitis;
Valyti(left, pr, pradzioje, g);
if (left < 0)
left = 0;
}
}
}
}
It works than I call it from not class(i.e. from Timer event OnTimer), but than I try to call it from class method, function is unknown..
Variables, methods ant comments aren't in English, but I think this isn't matter, because you don't need to know what it does, only to see how I use it. I think you can help me :) (If it's better to paste all code, please ask)