PicShow not Random

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

PicShow not Random

Postby Tabakbrummel » November 7th, 2007, 6:54 pm

Hi
I come from Germany because the bad English.
My problem is that I PicShow not with the Random wants.



Code: Select all
// Selects randomly an image from the list and loads it in to PicShow
procedure TMainForm.LoadNextImage;
var
  Index: Integer;
begin
  LoadedImage := '';
  if Pictures.Count > 0 then
  begin
    repeat
      Index := Random(Pictures.Count);//What must I change there ???
    until (Pictures.Count <= 1) or (ShowingImage <> Pictures[Index]);
    LoadedImage := Pictures[Index];
    PicShow.Picture.LoadFromFile(PicturesPath + '\' + LoadedImage);
  end;
end;


Thank you
Uwe
Tabakbrummel
Member
Member
 
Posts: 2
Joined: November 7th, 2007, 6:01 pm
Location: Germany, Berlin

Postby Kambiz » November 7th, 2007, 9:04 pm

I guess you need the following code:

Code: Select all
var
  LoadedIndex: Integer = -1;

procedure TMainForm.LoadNextImage;
begin
  if Pictures.Count > 0 then
  begin
    Inc(LoadedIndex);
    if LoadedIndex >= Pictures.Count then
      LoadedIndex := 0;
    LoadedImage := Pictures[LoadedIndex];
    PicShow.Picture.LoadFromFile(PicturesPath + '\' + LoadedImage);
  end;
end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby Tabakbrummel » November 7th, 2007, 9:14 pm

Hi Kambiz

First, many thanks to a lot of work and greetings from Germany.

Thank you
Uwe
Tabakbrummel
Member
Member
 
Posts: 2
Joined: November 7th, 2007, 6:01 pm
Location: Germany, Berlin

Postby Kambiz » November 8th, 2007, 10:50 pm

You're welcome!
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron