2016-08-19 1 views
0

Erste Schritte mit Embarcadero XE-5, das Objektmodell hat mich verwirrt. Mein Projekt beinhaltet die Canvas von Anfang an, also meine Hallo Welt ist eine Linie oder zwei zu zeichnen. Richten Sie ein SDI-Projekt ein und fügten einen Schnellaufruf direkt aus der C++ Builder-Hilfe hinzu, aber es kann nicht zum Kompilieren gebracht werden. Form1 wird in allen Beispielen verwendet, aber meine Bemühungen, es zu instanziieren, funktionieren nicht . Ich habe versucht, Form1 auf verschiedene Arten zu deklarieren, keinen Erfolg.Formular in Embarcadero C++ Builder deklarieren:

Kann jemand bitte meinen Fehler aufzeigen?

// ---------------------------------------------------- 
#include <vcl.h> 
#pragma hdrstop> 
#include <tchar.h> 
//----------------------------------------------------- 
USEFORM("SDIMAIN.CPP", SDIAppForm); 
USEFORM("ABOUT.CPP", AboutBox); 
//----------------------------------------------------- 
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) 
    { 
    Application->Initialize(); 
    Application->CreateForm(__classid(TSDIAppForm), &SDIAppForm); 

// ** Following line gives error: Form1 undefined. ** 
    Application->CreateForm(__classid(TCanvas), &Form1); 
    Application->CreateForm(__classid(TAboutBox), &AboutBox); 
    Application->Run(); 

    return 0; 
    } 
//------------------------------------------------------ 

/* SDIMAIN - copied from the help screens */ 
void __fastcall TForm1::FormPaint(TObject *Sender) 
{ 
Canvas->MoveTo(0,0); 
Canvas->LineTo(ClientWidth, ClientHeight); 
Canvas->MoveTo(0, ClientHeight); 
Canvas->LineTo(ClientWidth, 0); 
} 

Antwort

0

Sie nicht TApplication::CreateForm() verwenden TCanvas Objekte zu erstellen. Ändern __classid(TCanvas)-__classid(TForm1) statt:

// ---------------------------------------------------- 
#include <vcl.h> 
#pragma hdrstop> 
#include <tchar.h> 
//----------------------------------------------------- 
USEFORM("SDIMAIN.CPP", SDIAppForm); 
USEFORM("Unit1.cpp", Form1); 
USEFORM("ABOUT.CPP", AboutBox); 
//----------------------------------------------------- 
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) 
{ 
    Application->Initialize(); 
    Application->CreateForm(__classid(TSDIAppForm), &SDIAppForm); 
    Application->CreateForm(__classid(TForm1), &Form1); 
    Application->CreateForm(__classid(TAboutBox), &AboutBox); 
    Application->Run(); 
    return 0; 
} 
//------------------------------------------------------ 

Natürlich, das Sie eine TForm1 Klasse haben muss beginnen:

Datei> Neu> VCL-Formular

Verwandte Themen