Autor Beitrag
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mo 28.02.11 14:52 
Moin Forum,
seht Euch mal folgenden Code an:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure THauptForm.LMDSpeedButtonF10Click(Sender: TObject);
begin
  Close;
end;

procedure THauptForm.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
  if Key = VK_F10
   then Close;
end;


Wenn ich LMDSpeedButtonF10 mit der Maus klicke, dann bekomme ich ein Zugriffsverletzung an Adresse 00000000, F-Taste F10 funktioniert ohne Fehler.
Aber warum?

Auch das hier funzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure THauptForm.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
  if Key = VK_F10
   then LMDSpeedButtonF10Click(nil);
end;



Ich habe mir jetzt so geholfen, da gehts dann auch per Mausklick auch ohne Fehler.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure THauptForm.LMDSpeedButtonF10Click(Sender: TObject);
begin
  PostMessage(HauptForm.Handle,WM_CLOSE,0,0);
end;


Aber jetzt tritt das Problem auch in einem anderen Formular auf.
Ich hoffe Ihr könnt mir helfen? Danke im voraus!

Gruß, Oliver

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 02.03.11 08:47 
*push*

Hat keiner eine Idee, wie so etwas zu Stande kommen könnte?
Ich habe das Problem jetzt auch in einem anderen Formular....

Gruß Oliver

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 02.03.11 09:00 
Naja, hast du es denn einmal mit einem normalen Speedbutton versucht?
Und wo genau tritt denn die Zugriffsverletzung auf, wenn es dort auch auftreten sollte?
Gerd Kayser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 632
Erhaltene Danke: 121

Win 7 32-bit
Delphi 2006/XE
BeitragVerfasst: Mi 02.03.11 09:38 
Ich habs hier mit D2006 und XE unter Windows 7 32-Bit getestet. Es funktioniert einwandfrei. Daß das Problem jetzt auch bei einem anderen Formular auftritt, deutet für mich darauf hin, daß Du vielleicht irgendwo Speicherstellen in Deinem Programm überschreibst.
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 02.03.11 09:58 
In dem anderen Formular ist es übrigens ein normaler TButton.

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...