AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Timer String Problem?

Ein Thema von gee21 · begonnen am 12. Okt 2019 · letzter Beitrag vom 13. Okt 2019
Antwort Antwort
gee21

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

Timer String Problem?

  Alt 12. Okt 2019, 19: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
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#2

AW: Timer String Problem?

  Alt 12. Okt 2019, 21:17
Du merkst dir nichts. selopt ist eine lokale Variable. Wenn die Prozedur durchgelaufen ist und wieder aufgerufen wird, steht da besten falls nichts drin.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
gee21

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

AW: Timer String Problem?

  Alt 12. Okt 2019, 21:27
Du merkst dir nichts. selopt ist eine lokale Variable. Wenn die Prozedur durchgelaufen ist und wieder aufgerufen wird, steht da besten falls nichts drin.
achso danke dir
Robert
  Mit Zitat antworten Zitat
Delphi-Laie

Registriert seit: 25. Nov 2005
1.474 Beiträge
 
Delphi 10.1 Berlin Starter
 
#4

AW: Timer String Problem?

  Alt 12. Okt 2019, 22:40
Und nicht auf "= true" und "= false" prüfen, das ist unelegant. Besser ist einfach "if" bzw. "if not...".
  Mit Zitat antworten Zitat
Redeemer

Registriert seit: 19. Jan 2009
Ort: Kirchlinteln (LK Verden)
1.010 Beiträge
 
Delphi 2009 Professional
 
#5

AW: Timer String Problem?

  Alt 13. Okt 2019, 13:27
Wenn die Prozedur durchgelaufen ist und wieder aufgerufen wird, steht da besten falls nichts drin.
In lokalen string-Variablen (außer dem Funktionsergebnis) steht anfangs immer nichts drin.
Janni
2005 PE, 2009 PA, XE2 PA
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#6

AW: Timer String Problem?

  Alt 13. Okt 2019, 14:43
Bei Strings war ich mir nicht sicher, ob nicht doch eventuell Schrott drin stehen könnte. Macht aber in diesem Fall nichts, da der Inhalt nach abarbeiten der Prozedur eh verloren ist.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz