Witam. Chcę aby aplikacae tworzyła obiekty danej klasy wraz z obrazem.
C++ Builder 10.4 nie wywala błędów, ale po uruchomieniu i kliknięciu odpowiedniego przycisku nic się nie pojawia.
Main.cpp:
#include <vcl.h>
#include <iostream>
#include <windows.h>
#include <time.h>
#pragma hdrstop
#include "Main.h"
#include "Envi.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
...
void __fastcall TForm1::BNewClick(TObject *Sender)
{
void __fastcall Startgame();
}
void __fastcall Startgame()
{
Envi Tree1("tree",100,100);
Tree1.Postaw();
}
Envi.cpp:
#include <Classes.hpp>
#include <vcl.h>
#include "Envi.h"
Envi::Envi(AnsiString typ, int to, int le)
{
typek=typ;
tto=to;
lle=le;
}
void __fastcall Envi::Postaw()
{ TImage *Image1;
if(typek=="tree")
{
Image1 -> Picture ->LoadFromFile("source/drzewo.png");
}
Image1 -> Top = tto;
Image1 -> Left = lle;
Image1 -> Height = 32;
Image1 -> Width = 32;
Image1 -> Visible = true;
}
Envi.h:
#include <Classes.hpp>
#include <Controls.hpp>
#include <vcl.h>
class Envi
{
public:
AnsiString typek;
int tto, lle;
TImage *Image1;
Envi(AnsiString="tree", int=0, int=0);
~Envi();
void __fastcall Postaw();