各位大大,第一次來上來問問題...所以問的問題可能有點笨~我是想要使用兩個自行規劃的記憶體位置來load圖檔,再加上timer來作...可是,為何只能做第一次呢?然後就會出現錯誤!他說是記憶體位置錯誤~感覺上好像是記憶體未釋放??~請大大幫我解答一下> <謝謝~~以下是我的程式碼: #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMemoryStream *a,*b;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
a=new TMemoryStream;
b=new TMemoryStream;
Timer1->Enabled=true;
Timer1->Interval=2000;
Timer2->Enabled=true;
Timer2->Interval=3000; }
//--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender)
{ a->LoadFromFile("C://Documents and Settings/JohnKart/My Documents/BCB/0.bmp");
Image1->Picture->Bitmap->LoadFromStream(a);
b->LoadFromStream(a);
delete a;
Image2->Picture->Bitmap->LoadFromStream(b);
delete b; }
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer2Timer(TObject *Sender)
{
delete Image1;
delete Image2;
}