上圖開了我這兩個同樣的程式。左上、右下。 左上:
在主form還沒load進bmp時,主form秀出的第二個form,
按下page1的按扭後可以正常執行。
右下:
load進一個20mb左右的圖後(事實上,就算load進一個只到1mb的圖,情況也是相同)
就會出現錯誤訊息->list index out of bound(1)-->(做Tstringlist的運算出現的錯誤)。 試過,不管讀進TXT檔(can't open file"...txt")或連接手機(can find device)
,在已開圖的狀況下,都會出現錯誤。在未開圖的情況下都正常。 另外,也試過在開圖的情況下,把會錯誤的的動作移到主form的"座標"這個按扭去做,
而不讓次要的form出來,卻也會發生錯誤 TOT。看來是第一個FORM的程式有問題…
可是我裡面沒寫什麼啊 +_+||| 第一個FROM的CODE如下。請各位長輩幫忙一下,感激不盡。
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#include "Unit1.h"
//#include "Unit1.cpp"
TMainForm *MainForm;
Graphics::TBitmap *Bmp = new Graphics::TBitmap(); //---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{ }
//--------------------------------------------------------------------------- void __fastcall TMainForm::N2Click(TObject *Sender)
{
OpenPictureDialog1->Filter = GraphicFilter(__classid(Graphics::TBitmap));
if (OpenPictureDialog1->Execute())
{
Bmp->Dormant(); // Free up GDI resources
Bmp->FreeImage(); // Free up Memory
Bmp->ReleaseHandle();
Bmp->LoadFromFile(OpenPictureDialog1->FileName); Image1->Width = Bmp->Width;
Image1->Height = Bmp->Height;
Image1->Picture->Bitmap = Bmp; Bmp->Canvas->Rectangle(0,0,Bmp->Width,Bmp->Height);
StatusBar1->Panels->Items[1]->Text=IntToStr(Bmp->Width)+" x "+IntToStr(Bmp->Height);
}
}
//--------------------------------------------------------------------------- void __fastcall TMainForm::N3Click(TObject *Sender)
{
Bmp->Dormant();
Bmp->FreeImage();
Bmp->ReleaseHandle();
delete Bmp;
//Image1->Picture->Bitmap = Bmp;
//Image2->Picture->Bitmap = Bmp;
}
//--------------------------------------------------------------------------- void __fastcall TMainForm::N4Click(TObject *Sender)
{
if (Image1->Picture->Bitmap->Empty==true)
ShowMessage("no Image to Save");
else
{
SavePictureDialog1->Filter = GraphicFilter(__classid(Graphics::TBitmap));
if (SavePictureDialog1->Execute())
{
Image1->Picture->SaveToFile(SavePictureDialog1->FileName + ".bmp"); }
}
}
//--------------------------------------------------------------------------- void __fastcall TMainForm::N5Click(TObject *Sender)
{
delete Bmp;
exit(0);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::PaintBox1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{ if (Image1->Picture->Bitmap->Empty==false)
{ PaintBox1->Canvas->CopyRect(PaintBox1->ClientRect, Image1->Canvas,
Image1->ClientRect);
PaintBox1->Canvas->Brush->Style=bsClear;
PaintBox1->Canvas->Pen->Style=psDot;
PaintBox1->Canvas->Pen->Color=clBlack;
PaintBox1->Canvas->MoveTo(X, 0);
PaintBox1->Canvas->LineTo(X, PaintBox1->Height);
PaintBox1->Canvas->MoveTo(0, Y);
PaintBox1->Canvas->LineTo(PaintBox1->Width, Y);
StatusBar1->Panels->Items[0]->Text="X:"+IntToStr(X)+" " + "Y:"+IntToStr(Y);
//StatusBar1->Panels->Items[1]->Text="Y:"+IntToStr(Y);
//StatusBar1->Panels->Items[0]->Text=X;//"X:" + X;
//StatusBar1->Panels->Items[1]->Text=Y;//"Y:" + Y; }
}
//--------------------------------------------------------------------------- void __fastcall TMainForm::StatusBar1DrawPanel(TStatusBar *StatusBar,
TStatusPanel *Panel, const TRect &Rect)
{
AnsiString sz;
if(Panel->Index==0)
{
//StatusBar1->Canvas->Brush->Color=clYellow;
StatusBar1->Canvas->Font->Name="X";
//StatusBar1->Canvas->Font->Color=clBlue;
sz="X:";
}
else if(Panel->Index==1)
{
//StatusBar1->Canvas->Brush->Color=clGreen;
StatusBar1->Canvas->Font->Name="Y";
//StatusBar1->Canvas->Font->Color=clRed;
sz="Y:";
}
else if(Panel->Index==2)
{
//StatusBar1->Canvas->Brush->Color=clGreen;
StatusBar1->Canvas->Font->Name="標楷體";
//StatusBar1->Canvas->Font->Color=clRed;
sz="1";
}
//StatusBar1->Canvas->FillRect(Rect);
// StatusBar1->Canvas->Brush->Style=bsClear;
//StatusBar1->Canvas->TextOutA(Rect.Left+2, Rect.Top+2, sz); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::N7Click(TObject *Sender)
{
PhoneOP->Show();
}
//---------------------------------------------------------------------------
發表人 - GeorgeZ 於 2004/05/17 01:32:21 發表人 - taishyang 於 2004/05/17 15:39:19