Einzelnen Beitrag anzeigen

gee21

Registriert seit: 3. Jan 2013
199 Beiträge
 
Delphi 10.4 Sydney
 
#1

Timer String Problem?

  Alt 12. Okt 2019, 18:55
Hallo

Ich wollte in meinem Programm 4 Bilder laden wenn die Maus über eine bestimmte Radiogroup fährt.
dazu habe ich folgenden Code in einem Timer um die Mausposition abzufragen und die Bilder zu laden.

Damit nun die Bilder nicht immer und immer wieder geladen werden solange der User die Mausposition NICHT verändert, wollte ich das zuletzt geladene Bild mit einem String "merken"

Leider scheint das so nicht zu klappen obwohl der string zu r1 gesetzt wird(das sehe ich im memo), werden die Bilder trotzdem immer und immer wieder geladen.... WAS MACHE ICH FALSCH?

Delphi-Quellcode:
procedure TForm2.Timer2Timer(Sender: TObject);
var
selopt: string;

begin


  if selopt = 'r1' = false then if radiogroup3.Visible=true then
  if mouse.CursorPos.x>form2.Left+panel8.Left+radiogroup3.Left then
  if mouse.CursorPos.x<form2.Left+panel8.Left+radiogroup3.Left+radiogroup3.Width then
  if mouse.CursorPos.y>form2.top+panel2.top+panel8.Top+panel6.Top+radiogroup3.top+panel5.Height then
  if mouse.CursorPos.y<form2.top+panel5.Height+panel2.top+panel6.Top+panel8.Top+radiogroup3.top+radiogroup3.height then begin

  if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC1.jpg') then Image1.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC1.jpg') else image1.Picture:=nil;
  if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC1.jpg') then Image2.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC1.jpg') else image2.Picture:=nil;
  if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC2.jpg') then image3.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC2.jpg') else image3.Picture:=nil;
  if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC3.jpg') then image4.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT1_PIC3.jpg') else image4.Picture:=nil;

  selopt:='r1';

  form5.Memo1.Lines.Add(selopt);
  end;



 if selopt = 'r2' = false then if radiogroup4.Visible=true then
 if mouse.CursorPos.x>form2.Left+panel8.Left+radiogroup4.Left then
 if mouse.CursorPos.x<form2.Left+panel8.Left+radiogroup4.Left+radiogroup4.Width then
 if mouse.CursorPos.y>form2.top+panel2.top+panel8.Top+panel6.Top+radiogroup4.top+panel5.Height then
 if mouse.CursorPos.y<form2.top+panel5.Height+panel2.top+panel6.Top+panel8.Top+radiogroup4.top+radiogroup4.height then begin

 if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC1.jpg') then Image1.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC1.jpg') else image1.picture:=nil;
 if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC1.jpg') then Image2.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC1.jpg') else image2.picture:=nil;
 if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC2.jpg') then image3.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC2.jpg') else image3.picture:=nil;
 if tfile.Exists(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC3.jpg') then image4.Picture.LoadFromFile(programmpfad+'MEDIA\'+selectedid+'_OPT2_PIC3.jpg') else image4.picture:=nil;

  selopt:='r2';

  form5.Memo1.Lines.Add(selopt);
 end;
Robert
  Mit Zitat antworten Zitat