Einzelnen Beitrag anzeigen

Dennis_Wolfram

Registriert seit: 8. Dez 2007
Ort: Berlin & Augsburg
29 Beiträge
 
Delphi 2010 Enterprise
 
#1

Brauche Eure Hilfe... Finde mein(e) Fehler nicht

  Alt 22. Nov 2008, 09:36
Hallo liebe Delphi-Freunde!

Dennis ist's mal wieder mit seinen Verständnis-Problemen.

Schreibe ein Programm für mein Abi.

Problem ist, dass die Aeroeffekte und alle Vista-Komponenten unter Vista benutzt werden sollen. An der Schule, wo das Programm auch genutzt werden sollen, wird aber Windows-XP benutzt. Bei meinen Abi-Prüfern wird Vista benutzt.
Ich hab also folgende Procedure geschrieben um zu erkennen ob Vista benutzt wird oder nicht:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, jpeg, ExtCtrls, StdCtrls, GlowLabel, WindowsVersionInfo;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    GlowLabel1: TGlowLabel;
    GlowLabel2: TGlowLabel;
    GlowLabel3: TGlowLabel;
    GlowLabel4: TGlowLabel;
    GlowLabel5: TGlowLabel;
    GlowLabel6: TGlowLabel;

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    procedure WindowsVersion;
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.WindowsVersion;
var winInfo : TOSVersionInfo;
begin
  winInfo.dwOSVersionInfoSize := sizeof (OSVERSIONINFO);
  GetVersionEx (winInfo);
  if winInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
    begin
      if ((winInfo.dwMajorVersion = 6) and (winInfo.dwMinorVersion = 0)) then
        begin
          // Windows-Vista wird verwendet... Vista-Effekte werden aktiviert
          //Form1:
          Form1.GlassFrame.Enabled := True;
          Form1.Image1.Hide;
          Form1.SpeedButton1.Font.Color := clBlack;
          Form1.SpeedButton2.Font.Color := clBlack;
          Form1.GlowLabel1.Font.Color := clBlack;
          Form1.GlowLabel2.Font.Color := clBlack;
          Form1.GlowLabel3.Font.Color := clBlack;
          Form1.GlowLabel4.Font.Color := clBlack;
          Form1.GlowLabel5.Font.Color := clBlack;
          Form1.GlowLabel6.Font.Color := clBlack;
          //Form2;
          Form2.GlassFrame.Enabled := True;
          Form2.Image1.Hide;
          Form2.Image2.Hide;
          Form2.Bevel1.Height := 230;
        end
      else
        begin
          // Windows-XP wird verwendet... Vista-Effekte werden deaktiviert
          ShowMessage ('Sie benutzen leider kein Windows Vista, daher werden die Glas-Effekte deaktiviert.');
          //Form1:
          Form1.GlassFrame.Enabled := False;
          Form1.Image1.Show;
          Form1.SpeedButton1.Font.Color := clWhite;
          Form1.SpeedButton2.Font.Color := clWhite;
          Form1.GlowLabel1.Font.Color := clWhite;
          Form1.GlowLabel2.Font.Color := clWhite;
          Form1.GlowLabel3.Font.Color := clWhite;
          Form1.GlowLabel4.Font.Color := clWhite;
          Form1.GlowLabel5.Font.Color := clWhite;
          Form1.GlowLabel6.Font.Color := clWhite;
          //Form2;
          Form2.GlassFrame.Enabled := False;
          Form2.Image1.Show;
          Form2.Image2.Show;
          Form2.Bevel1.Height := 0;
        end;
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DoubleBuffered := True;
  WindowsVersion;
end;

.
.

end.
In den anderen Formularen (Form2, Form3 ... Form20) fangen die entsprechenden Units wie folgt an:

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, jpeg, CategoryButtons;

type
  TForm2 = class(TForm)
    Bevel1: TBevel;
    Image1: TImage;
    Image2: TImage;
    CategoryButtons1: TCategoryButtons;
    procedure FormCreate(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
 DoubleBuffered := True;
 Form1.WindowsVersion;
end;

end.
So wenn ich nun das Programm benutzen möchte soll es beim Starten(TForm.Create ... Form1.WindowsVersion rausbekommen ob ich Vista benutze. Wenn ja dann sollen die Glas-Effekte aktiviert und die ganzen Vista-Komponenten benutzt werden. Wenn ich dagegen eine ältere Version von Windows als Vista benutze dann sollen diese ganzen Eigenschaften deaktiviert werden.

Wenn ich meine Anwendung aber nun aus führe (F9) gibt er mir eine Fehlermeldung zurück. Irgendetwas von Zugriffsverletzung oder so. Ich finde einfach nicht meine(n) Fehler.
Über Eure Hilfe währe ich wie immer sehr verbunden!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dennis Wolfram
  Mit Zitat antworten Zitat