Autor Beitrag
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Sa 23.12.06 16:53 
Habe ein ScrollBar auf der Form. Wenn es angesprochen wird, erscheint in Abhängigkeit von einem Flag eine Message. Problem: beim klicken auf OK poppt die Message mindestens noch einmal auf (wenn der Button im ScrollBar angeklickt wurde, sogar noch zweimal), bevor sie endgültig verschwindet. Wie kann man das verhindern?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm2.ScrollBar2Scroll(Sender: TObject; ScrollCode: TScrollCode;
  var ScrollPos: Integer);
begin
  if VFOflg then
    begin
      DDS := 400e6 + Trunc(ScrollPos);
      FreqCorr.Caption := FloatToStrF(DDS/1000,fffixed,15,3);
      //... usw.
    end
  else
    ShowMessage('Frequenzkorrektur nur im VFO-Modus möglich');
end;
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 23.12.06 17:24 
Hallo,

spricht irgendwas dagegen das Ereignis OnChange zu verwenden?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
aim65 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Sa 23.12.06 17:42 
Danke Lannes, hab's gerade ausprobiert - geht mit OnChange. :lol: Ich hätte trotzdem gerne gewußt, warum das bei OnScroll passiert. Falls das jemand weiß..... :idea:
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 23.12.06 18:44 
Hallo,

damit man direkter auf Scrollaktionen reagieren kann.
Ausgelöst wird OnScroll bei MouseDown, MouseMove und MouseUp.

Kannst Dir ja die Events mal in einem Memo aufzeichnen lassen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
  var ScrollPos: Integer);
begin
  Memo1.Lines.Add(IntToStr(ScrollPos)+'    '+IntToStr(ScrollBar1.Position));
end;
Und schau Dir mal die unterschiedlichen Werte an.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
aim65 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Sa 23.12.06 20:07 
Das ist mir schon klar.
Aber wieso passiert das mehrfache Pop-Up? :gruebel: Das Drücken des OK-Buttons ist ja kein Scrollereignis mehr. Die MessageBox liegt übrigens außerhalb des ScrollFeldes. Schwirren da noch Windows-Msgs herum - und falls ja, könnte man die abfangen?
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 23.12.06 21:16 
Hallo,

user profile iconLannes hat folgendes geschrieben:

Ausgelöst wird OnScroll bei MouseDown, MouseMove und MouseUp.


Also:
Du klickst auf die Scrollbar > MouseDown > OnScroll > MessageBox
Die Folge > MouseUp > OnScroll > neue MessageBox
Wenn dazwischen noch > MouseMove > OnScroll > noch eine MessageBox

Durch die Anzeige der ersten MessageBox werden die aufgetretenen Ereignisse nicht aus der Nachrichtenschlange (queue) gelöscht, sie werden danach abgearbeitet und lösen die erneute(n) Anzeige(n) der MessageBox aus.

Man kann mehr oder weniger alles abfangen, reicht dir bei Deinem Problem denn der Umstieg auf OnChange nicht?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
aim65 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Sa 23.12.06 23:13 
Doch, OnChange reicht in diesem Fall völlig - daher auch das Erledigt-Häkchen.

Hat mich eben nur interessiert, wie man im anderen Fall so etwas abfängt.
Nochmal, Danke für die ausführliche Erklärung. :D