Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 18:34 
Hallo,

ich habe ein Problem mit der JVCL-Komponente TJvDriveList. Wenn ich ImageSize auf isLarge stelle und mein Programm starte, kriege ich eine Exception, wonach ein Listenindex überschritten wurde. Das passiert übrigens nur, wenn ich alle optischen Laufwerke (CD/DVD/BluRay) deaktiviert habe.

Das ist sicherlich ein Bug, aber wie kann ich das ganze denn zur Laufzeit noch abfangen?

Vielen Dank!

Bye
Garf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 54
Erhaltene Danke: 2


D3Prof, D7PE, TDE
BeitragVerfasst: Fr 06.11.09 19:49 
Maximum(0) bedeutet, dass die Liste leer ist. Der Listenindex dürfte dann -1 sein. Den Fehler fängt man ab, indem man vor dem Zugriff prüft, ob die Liste Einträge besitzt, also Laufwerke eingetragen sind.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 19:52 
Das Problem ist, dass der Fehler schon auftritt, wenn die Komponente erzeugt wird und ihr Konstruktor abläuft.

Wenn ich etwas prüfen will, geht das ja erst, *nachdem* die komponente bereits erzeugt wurde.

Wie löse ich dieses Dilemma :(?
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 06.11.09 20:14 
a) Neueste JVCL version?
b) Bei der JVCL liegt doch der Quellcode bei -> selber debuggen und korrigieren, und danach den Patch einschicken ;)

_________________
PROGRAMMER: A device for converting coffee into software.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 20:35 
3.38 ist die Version, die ich installiert habe.

Und daran selbst rumfrickeln, das überlasse ich lieber denjenigen, die das ganze wirklich durchschauen ;)

Edit: Auch ein Updaten auf 3.39 hat nichts gebracht :(
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Fr 06.11.09 21:01 
Du kannst die Komponente manuell erzeugen und einen try-except-Block um das Create herumbauen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  list: TJvDriveList;
begin
  try
    list := TJvDriveList.Create(Self);
  except
    //Fehlermeldung schlucken oder in LOG speichern, etc.
  end;
  list.Parent := Self;
  ...
end;
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 21:09 
Stimmt, das ist eine Lösung. Aber ich dachte, es geht irgendwie anders ;)

Naja, ich habe den Bug beim Bugtracker von JEDI gemeldet.
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 06.11.09 21:15 
user profile iconAndreas L. hat folgendes geschrieben Zum zitierten Posting springen:
Du kannst die Komponente manuell erzeugen und einen try-except-Block um das Create herumbauen.


das kaschiert aber nur das Problem und irgendwann fällt einem das dann auf den Kopf, weil es nicht mehr sichtbar ist. Also schön ist eindeutig was anderes.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 21:18 
Naja, hast du eine schönere Idee?

Edit: Leider geht folgendes nicht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  DriveList1: TJvDriveList;
begin
  try
    DriveList1 := TJvDriveList.Create(Self);
  except
    //Fehlermeldung schlucken oder in LOG speichern, etc.
  end;
  if DriveList1 <> nil then begin
    DriveList1.Parent := Self;
    DriveList1.ImageAlign := iaLeft; // [DCC Fehler] xy.pas(115): E2010 Inkompatible Typen: 'TJvImageAlign' und 'TImageAlignment'
    DriveList1.ImageSize := isLarge; // [DCC Fehler] xy.pas(116): E2003 Undeklarierter Bezeichner: 'isLarge'
  end;
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 06.11.09 21:23 
Problem selber fixen oder warten bis es gefixt ist. Selbst ist der Mann, die Axt im haus erspart den zimmermann, lirum larum löffelstiel..., und so weiter. ich glaub man weiß was ich ausdrücken will^^

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 21:26 
Nun ja, ich sehe da nicht sooo durch, dass ich mir das zutrauen würde. Vielleicht ist es ja nur 1 Zeile (was allerdings zu bezweifeln ist).

Und mit warten ist so ne Sache in der Softwareentwicklung ;)
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 06.11.09 21:33 
Listenindex überschreitet Maximum klingt so, als würde da nur irgendwo ein -1 fehlen.. also 1 Zeile ;)
Springt der bei der Exception nicht bis an die Stelle, wo das auftritt? Oder hast du die .pas Dateien davon nicht im Suchpfad?

_________________
PROGRAMMER: A device for converting coffee into software.
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Fr 06.11.09 22:14 
user profile iconLonghornUser hat folgendes geschrieben Zum zitierten Posting springen:
[DCC Fehler] xy.pas(115): E2010 Inkompatible Typen: 'TJvImageAlign' und 'TImageAlignment'
[DCC Fehler] xy.pas(116): E2003 Undeklarierter Bezeichner: 'isLarge'


Hört sich so an als wenn noch eine Unit fehlt. Was steht alles in deiner Uses-Klausel?
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Fr 06.11.09 22:19 
Er springt nach dem Fehler direkt an die Stelle, wo die Form nach der Form, wo die jvDriveList liegt, created wird.

Du kannst das ganze ganz leicht testen: Als erstes deaktivierst du alle optischen Laufwerke über Arbeitsplatz->Rechtsklick auf ein Laufwerk->Hardware->Ein Laufwerk anwählen->Eigenschaften->Treiber->Deaktivieren. Lege eine jvDriveList auf eine neue Form und stelle bei DriveTypes nur dtCDROM ein.

Dann setzt du ImageSize auf isLarge (hier könnte schon der erste Fehler kommen) und startest das Programm. Dann kommt der Fehler.

Wenn du Ahnung hast, wäre es wirklich super, wenn du mal nachschauen könntest, ob du den Fehler findest.

Edit:
user profile iconAndreas L. hat folgendes geschrieben Zum zitierten Posting springen:
user profile iconLonghornUser hat folgendes geschrieben Zum zitierten Posting springen:
[DCC Fehler] xy.pas(115): E2010 Inkompatible Typen: 'TJvImageAlign' und 'TImageAlignment'
[DCC Fehler] xy.pas(116): E2003 Undeklarierter Bezeichner: 'isLarge'


Hört sich so an als wenn noch eine Unit fehlt. Was steht alles in deiner Uses-Klausel?


ausblenden Delphi-Quelltext
1:
2:
3:
4:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, ExtCtrls, JvExExtCtrls, JvImage,
  JvExStdCtrls, JvDriveCtrls, IniFiles, JvListBox, GIFImg;
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Fr 06.11.09 22:35 
Du kannst dir so eine Liste ganz leicht selber bauen. Das Kernstück wäre das hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure GetDrives(const AItems: TStrings);
const
  DriveTypeTexts: array[DRIVE_UNKNOWN..DRIVE_RAMDISK] of String =
   ('Unbekannt', 'Kein Wurzelverzeichnis', 'Diskette', 'Festplatte', 'Netzlaufwerk', 'CDROM', 'RAMDisk');
var
  Drive: Char;
  DriveType: Integer;
  DriveMask: Integer;
  Flag: Integer;
begin
  DriveMask:=GetLogicalDrives;
  flag:=1;
  for Drive := 'A' to 'Z' do
  begin
    if (flag and DriveMask)<>0 then
    begin
      DriveType := GetDriveType(PChar(Format('%S:\',[Drive]) ) ) ;
      AItems.Add(Format('%s: %s', [Drive, DriveTypeTexts[DriveType]]));
    end;
    flag:=flag shl 1;
  end;
end;

Musst halt so anpassen das nur CD-Laufwerke ermittelt werden (DriveType-Abfragen) und die Bilder kannst du mit SHGetFileInfo ermitteln. Das ganze noch auf eine ListView umstellen und fertig.
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: Sa 07.11.09 08:36 
Mit JVCL 3.36 kann ich das Problem nicht reproduzieren. Könntest du eine Beispiel-Exe bitte anhängen? Einfach nur mit der Komponente um zu testen ob es hier dann reproduzierbar ist oder es an deinem PC liegt.

Ich werde nachher schnell die JVCL Version durch die neuere ersetzen. Da ich die ohnehin nicht installiert sondern nur im Bibliothekspfad eingetragen habe, geht das ja blitzschnell nach dem Download.
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Sa 07.11.09 13:26 
Hier anbei ein Beispiel-Projekt (mit EXE), was genau den Fehler produziert, um den es mir geht (wie gesagt, nur, wenn man alle CD/DVD/BluRay-Laufwerke deaktiviert bzw. den Stecker zieht).
Einloggen, um Attachments anzusehen!
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Sa 07.11.09 14:25 
So, ich habe jetzt diesen Code hier mit einer CheckListBox genommen:
swissdelphicenter.ch.../showcode.php?id=562

Klappt wunderbar. Aber die andere Variante war optisch schöner ;)
Garf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 54
Erhaltene Danke: 2


D3Prof, D7PE, TDE
BeitragVerfasst: Sa 07.11.09 16:30 
Das ist der Construktor:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
constructor TJvDriveList.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FLarge := GetSystemMetrics(SM_CXICON);
  FSmall := GetSystemMetrics(SM_CXSMICON);

  FDrives := TStringList.Create;
  FDriveTypes := dtStandard;
  FImageAlign := iaCentered;
  ScrollBars := ssNone;

  if FImageSize = isSmall then
    FImages := TImageList.CreateSize(FSmall, FSmall)
  else
    FImages := TImageList.CreateSize(FLarge, FLarge);

  FImages.DrawingStyle := dsTransparent;
  FImageWidth := FImages.Width;
  FImages.ShareImages := True;

  FItemIndex := 0;  // <- Ich denke, das müsste -1 sein
  Color := clWindow;
  SetBounds(0, 0, FImageWidth * 6 + 16, 97);
  FOffset := 4;
  Style := lbOwnerDrawFixed;
  ResetItemHeight;
  Application.HookMainWindow(DriveChangeMessage);
end;


user profile iconLonghornUser hat folgendes geschrieben Zum zitierten Posting springen:
So, ich habe jetzt diesen Code hier mit einer CheckListBox genommen:

Mit einem TListView müsste es doch auch gehen!?