遇到一个问题请教一下大家,关于resize bitmap的
-----一个简单的类----------
#ifndef Unit2H
#define Unit2H
#include <vcl.h>
//---------------------------------------------------------------------------
class TCopy : public TObject
{
public:
TCopy();
__fastcall ~TCopy();
void ResizeBitMap(int width,int height);
private:
Graphics::TBitmap *pBitmap;
};
#endif
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
TCopy::TCopy()
{
pBitmap = new Graphics::TBitmap;
}
__fastcall TCopy::~TCopy()
{
delete pBitmap;
}
void TCopy::ResizeBitMap(int width,int height)
{
pBitmap->Width = width;
pBitmap->Height = height;
}
-------------程序中--------------------------
TCopy * mybitmap;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
mybitmap = new TCopy;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete mybitmap;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
mybitmap->ResizeBitMap(Panel1->ClientWidth,Panel1->ClientHeight);
}
//---------------------------------------------------------------------------
------没有问题,以上是在一个空的form1中,然后加入一个mainmenu控件,输入几个菜单项,编译运行程序,也正常,但在关闭程序时错误了:
access violation at address ......
请问问题在哪里?