Slideshow

Tags:    c++ c++

User
Bruger #379 @ 22.04.03 09:43
Jeg har et lille problem, jeg er ved at programmer et lille program (i faget programmering) som skal vise billeder på skifte(et såkaldt slideshow), men da jeg hele tiden får den samme fejl, og jeg har ændre næsten hele kildekoden. hvis i er venlig at kikke på koden:

//---------------------------------------------------------------------------

#include <vcl.h>
#include <jpeg.hpp>
#pragma hdrstop

#include "slide.h"
//---------------------------------------------------------------------------

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm6 *Form6;

int filter = 1;
int Index = 0;
//---------------------------------------------------------------------------
__fastcall TForm6::TForm6(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm6::Button1Click(TObject *Sender)
{
AnsiString openfile;

TOpenDialog *O = new TOpenDialog(this);
O->Options.Clear();
O->Title = "Open file";
O->Filter = "Bitmap files (*.bmp)|*.bmp|Jpeg files (*.jpg, *.jpeg)|*.jpg";
O->FilterIndex = filter;
O->Options << ofAllowMultiSelect << ofFileMustExist;

if (O->Execute())
{
//openfile = O->FileName;
for(int i = 0; i < O->Files->Count; i++)
{
Memo1->Lines->Add(O->Files->Strings);

}
}
filter = O->FilterIndex;

}
//---------------------------------------------------------------------------
void __fastcall TForm6::Button2Click(TObject *Sender)
{
if(Timer1->Enabled)
{
Timer1->Enabled = false;
Button2->Caption = "Start";
}
else
{
Timer1->Interval = StrToInt(LabeledEdit1->Text);
Timer1->Enabled = true;
Button2->Caption = "Stop";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm6::Timer1Timer(TObject *Sender)
{
//if(Index != Memo1->Lines->Count)
//{
tjeck(Index+1, 2);


tjeck(Index+2, 3);

tjeck(Index, 1);
Index++;
// }
//if(Index == Memo1->Lines->Count)
// Index = 0;

}
//---------------------------------------------------------------------------
void __fastcall TForm6::tjeck(int ind, int dex)
{
TJPEGImage *jpeg = new TJPEGImage();
Graphics::TBitmap *bitmp = new Graphics::TBitmap();



if(ind <= Memo1->Lines->Count)
{
int long len = StrLen(Memo1->Lines->Strings[ind].c_str()) - 3;
Label2->Caption = Memo1->Lines->Strings[ind][len+1];
Label2->Caption = Label2->Caption + Memo1->Lines->Strings[ind][len+2] + Memo1->Lines->Strings[ind][len+3];
//Label2->Caption = Memo1->Lines->Strings[ind][len+1] + Memo1->Lines->Strings[ind][len+2] + Memo1->Lines->Strings[ind][len+3];
StatusBar1->SimpleText = "Current showing: " + Memo1->Lines->Strings[Index];


if(dex == 1)
{
if(Label2->Caption == "bmp")
{
bitmp->LoadFromFile(Memo1->Lines->Strings[ind]);
Image1->Picture->Bitmap->Assign(bitmp);
Image2->Picture->Bitmap->Assign(bitmp);
bitmp->Free();
}
if(Label2->Caption == "jpg")
{
jpeg->LoadFromFile(Memo1->Lines->Strings[ind]);
Image1->Picture->Bitmap->Assign(jpeg);
Image2->Picture->Bitmap->Assign(jpeg);
jpeg->Free();
}
}

if(dex == 2)
{
if(Label2->Caption == "bmp")
{
bitmp->LoadFromFile(Memo1->Lines->Strings[ind]);
Image3->Picture->Bitmap->Assign(bitmp);
bitmp->Free();
}
if(Label2->Caption == "jpg")
{
jpeg->LoadFromFile(Memo1->Lines->Strings[ind]);
Image3->Picture->Bitmap->Assign(jpeg);
jpeg->Free();
}
}

if(dex == 3)
{
if(Label2->Caption == "bmp")
{
bitmp->LoadFromFile(Memo1->Lines->Strings[ind]);
Image4->Picture->Bitmap->Assign(bitmp);
bitmp->Free();
}
if(Label2->Caption == "jpg")
{
jpeg->LoadFromFile(Memo1->Lines->Strings[ind]);
Image4->Picture->Bitmap->Assign(jpeg);
jpeg->Free();
}
}
}
else if(ind > Memo1->Lines->Count)
{
bitmp->LoadFromFile("c:\\\\pic\\\\Nopicture.bmp");
if(dex == 1)
{
Image1->Picture->Bitmap->Assign(bitmp);
Image2->Picture->Bitmap->Assign(bitmp);
}
if(dex == 2)
Image3->Picture->Bitmap->Assign(bitmp);

if(dex == 3)
Image4->Picture->Bitmap->Assign(bitmp);

bitmp->Free();
StatusBar1->SimpleText = "Current showing: Nopicture";
}

Image1->Stretch = true;
Image2->Stretch = true;
Image3->Stretch = true;
Image4->Stretch = true;

}
//--------------------------------------------------
/*
void __fastcall TForm1::LoadJPG(AnsiString JPGImage)
{
TJPEGImage *img = new TJPEGImage();
img->LoadFromFile(JPGImage);
Image1->Picture->Bitmap->Assign(img);

img->Free();
}
*/
//---------------------------------------------------------------------------

void __fastcall TForm6::Button3Click(TObject *Sender)
{

if(Index != Memo1->Lines->Count)
{
tjeck(Index, 1);
tjeck(Index+1, 2);
tjeck(Index+2, 3);
Index++;
}
if(Index == Memo1->Lines->Count)
Index = 0;

}
//---------------------------------------------------------------------------

void __fastcall TForm6::Image6Click(TObject *Sender)
{
Index--;
}
//---------------------------------------------------------------------------

void __fastcall TForm6::Image5Click(TObject *Sender)
{
Index++;
}
//---------------------------------------------------------------------------


Jeg bruger Borland Builder 6.0, den siger at der er fejl:
"Project mbmpview.exe raised exception class EAccessViolantion with message 'Access violation at address 40009720 in module 'rtl60.bpl'. Read of address EB582603'. Process Stopped. Use Step or Run to continue"

-----humor----[Redigeret d. 23/04-03 12:35:19 af Michael]




2 svar postet i denne tråd vises herunder
0 indlæg har modtaget i alt 0 karma
Sorter efter stemmer Sorter efter dato
Det ville være lidt nemmere hvis du viste hvilken fejl der kommer.
Typisk står der også noget med "Line 34 - Error: 'et eller andet er i vejen" eller hvor der
på anden måde står, hvilken linie der er tale om.




Hvis du måske prøver at laver det i flash, og får det omsat i ASP, eller PHP, burde det nok virke!



t