제가 빌더에서 PaintBox에 리소스 비트맵 그림 파일 그리려고 하거든요...
근데.. 안 나와요.. 책 보고 했는데... 소스는 다음과 같습니다....
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "tetris.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
tet1 = new Graphics::TBitmap();
tet2 = new Graphics::TBitmap();
tet3 = new Graphics::TBitmap();
back = new Graphics::TBitmap();
tet1->LoadFromResourceName((int)HInstance,"TET1");
tet2->LoadFromResourceName((int)HInstance,"TET2");
tet3->LoadFromResourceName((int)HInstance,"TET3");
back->LoadFromResourceName((int)HInstance,"BACK");
PaintBox1->Canvas->Draw(0,0,back);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete tet1;
delete tet2;
delete tet3;
delete back;
}
//---------------------------------------------------------------------------
그리구 헤더 파일에서는요...
//---------------------------------------------------------------------------
#ifndef tetrisH
#define tetrisH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TPaintBox *PaintBox1;
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
private:
Graphics::TBitmap* tet1, * tet2, * tet3, * back;
// User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
이렇게 됩니다. 물론, 프로젝트 관리자에 리소스 파일을 추가시켰습니다.
그래서 실행시켜보면 폼만 덜렁 나타나요... 어떻하죠??
.
|