遇到一个问题请教一下大家,关于resize bitmap的

hz780714 2007-01-21 07:46:15
-----一个简单的类----------
#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 ......

请问问题在哪里?
...全文
204 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hz780714 2007-01-21
  • 打赏
  • 举报
回复
是啊放在panel上就没有问题了,这难道是因为form和panel是继承的路线不一样么,form是winstrollcontrol什么的另一个是tcustomcontrol重载的resize方法不一样?
CsharpGame 2007-01-21
  • 打赏
  • 举报
回复
试了一下,也有这问题,可把此句改为
void __fastcall TForm1::Panel1Resize(TObject *Sender)
{
mybitmap->ResizeBitMap(Panel1->ClientWidth,Panel1->ClientHeight);
}
hz780714 2007-01-21
  • 打赏
  • 举报
回复
对了FormResize中是Form1->ClientWidth,Form1->ClientHeight

602

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧