Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi OnTime Exepction ? (https://www.delphipraxis.net/89553-ontime-exepction.html)

nitschchedu 2. Apr 2007 10:49


OnTime Exepction ?
 
Hallo alle,
also habe ne Bösses Problem ich habe ne OnTime und wenn das ausgeführt wird will ich
in einen ListView was auslesen.

Delphi-Quellcode:
ID := ListView1.Items[Pos].SubItems[14];
doch es gibt da immer eine Exepction :wall: !!!

Mit ne Button --> ButtonClick geht diese Zeile warum aber im OnTime nicht ? :gruebel:

Gruber_Hans_12345 2. Apr 2007 10:51

Re: OnTime Exepction ?
 
welche exception?
was ist pos, wo und auf was wird das gesetzt?

nitschchedu 2. Apr 2007 10:58

Re: OnTime Exepction ?
 
Also Pos ist ne Integer und beim aufruf der Funktion 0 also ich will damit den 1 Eintrag aus meinen ListView.
Die Exception "Zugrief auf Adressspeicher Sowieso blabla bla (eben eine Adresse)". Was man eben von Windows kennt.

Gruber_Hans_12345 2. Apr 2007 11:01

Re: OnTime Exepction ?
 
dann greifst du wohl auf eine postion zu, die nicht definiert ist, und deshalb gibts die AV

entweder ist Pos nicht innerhalb deiner Liste, oder der SubItem Index mit 14 ist zu hoch (zb. du hast keine 15 subelemente)

aber ohne mehr code kann man natürlich nur munter drauf los raten

Luckie 2. Apr 2007 11:03

Re: OnTime Exepction ?
 
Zitat:

Zitat von nitschchedu
Die Exception "Zugrief auf Adressspeicher Sowieso blabla bla (eben eine Adresse)". Was man eben von Windows kennt.

Was hat dein Fehler mit Windows zu tun? Der Fehler kommt nicht von Windows, sondern von deinem fehlerhaft programmierten Programm.

nitschchedu 2. Apr 2007 11:11

Re: OnTime Exepction ?
 
Das war ne vergleich :wink: !

Soweit wie ich das gezählt habe sind das 15 :gruebel: .

Delphi-Quellcode:
  var
   tpcolumn: TListColumn;
  begin

  ....

  ListView1.RowSelect:= TRUE;
  ListView1.MultiSelect:= TRUE;
  ListView1.showcolumnheaders := TRUE;
  ListView1.ReadOnly := TRUE;
  ListView1.ViewStyle := vsReport;

  ListView1.IconOptions.Arrangement := iaTop;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := 'Haupt ';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '1';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '2';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '3';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '4';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '5';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '6';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '7';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '8';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '9';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '10';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '11';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '12';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '13';
  tpcolumn.width := 40;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '14';
  tpcolumn.width := 60;

  tpcolumn := ListView1.Columns.Add;
  tpcolumn.Caption := '15';
  tpcolumn.width := 60;

  ....

So und damit kein Fusch passiert kommt noch vor der abfrage
Delphi-Quellcode:
  if ListView1.Items.Count = 0 then
  begin
     ShowMessage('Bitte erstmal was in die Liste eintragen!');
     Exit;
  end;
Und da ich den Eintrag sehe und er da vorbeikommt wundert mich das, das er da Abschmiert :gruebel: .

Gruber_Hans_12345 2. Apr 2007 11:12

Re: OnTime Exepction ?
 
Zitat:

Zitat von Luckie
Zitat:

Zitat von nitschchedu
Die Exception "Zugrief auf Adressspeicher Sowieso blabla bla (eben eine Adresse)". Was man eben von Windows kennt.

Was hat dein Fehler mit Windows zu tun? Der Fehler kommt nicht von Windows, sondern von deinem fehlerhaft programmierten Programm.

Na klar ist windows schuld, wenn windows nicht so böse wäre und den speicher von den anderen programmen schützen würde, dann würde diese AV ja auch nicht kommen ;)

Gruber_Hans_12345 2. Apr 2007 11:15

Re: OnTime Exepction ?
 
dann zeig noch den code her, wo du das machst ID := ListView1.Items[Pos].SubItems[14]; (also das drüber)

[edit]bzw. kontrolliere, das pos auch wirklich im bereich ist

nitschchedu 2. Apr 2007 11:21

Re: OnTime Exepction ?
 
Erstmal Windows ist doch immer Schuld :tongue: .

Ok hier so sieht das ganze aus.

Delphi-Quellcode:
procedure TfrmBot.Timer1Timer(Sender: TObject);
var
  ID: String;
  Href: String;
begin
  Timer1.Enabled := False;

  if LoginStatus then
  begin
     
    ID := ListView1.Items[Pos].SubItems[14];
    Href := Form1.WebBrowser1.OleObject.
      Document.Frames.item('main').
      Document.location.href;

     if Href <>
      'http://www.google.de/search.php?id=' +
       ID + '&suche=place' then
     begin
       exit;
     end;


     Form1.WebBrowser1.OleObject.Document.Frames.item('main').
      Document.Forms.item('units').Elements.item('x').value
      := ListView1.Items[Pos].Caption;
     Form1.WebBrowser1.OleObject.Document.Frames.item('main').
      Document.Forms.item('units').Elements.item('y').value
      := ListView1.Items[Pos].SubItems[0];
   end;

end;
:duck:

Gruber_Hans_12345 2. Apr 2007 11:39

Re: OnTime Exepction ?
 
und WO wird pos auf einen wert gesetzt?


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:53 Uhr.
Seite 1 von 3  1 23      

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