Delphi-PRAXiS

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 Incompatible types: 'TMouseButton' and 'TGLMouseButton' (https://www.delphipraxis.net/118624-incompatible-types-tmousebutton-tglmousebutton.html)

Pyr0cracker 11. Aug 2008 21:16


Incompatible types: 'TMouseButton' and 'TGLMouseButton'
 
Hi,
ich habe ein kleines Problem und hänge da gedanklich gerade fest...

Ich habe folgende Procedur:

Delphi-Quellcode:
procedure TSpiel.GLSceneViewer_SpielMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  //Konsole.Visible:= not Konsole.visible;
   case iModus of
       0:begin
        if Button = mbLeft then {linke maustaste}
        begin
[...]
Button bezieht sich auf TMouseButton in Controls.pas.
mbLeft ist leider erneut in GLCrossPlatform.pas unter TGLMouseButton (GLScene) definiert.
Zitat:

[Error] formSpiel.pas(169): Incompatible types: 'TMouseButton' and 'TGLMouseButton'
Gibts da eine Möglichkeit zu definieren, dass mbLeft aus Controls 'benutzt' wird?

Gruß,
Dorian

Dunkel 11. Aug 2008 21:19

Re: Incompatible types: 'TMouseButton' and 'TGLMouseButton'
 
Hallo!

Zitat:

Zitat von Pyr0cracker
Gibts da eine Möglichkeit zu definieren, dass mbLeft aus Controls 'benutzt' wird?

Setz einfach die entsprechende Unit vor den Bezeichner, in etwa so:
Delphi-Quellcode:
  if Button = Controls.mbLeft then {linke maustaste}
    { .. }

Pyr0cracker 11. Aug 2008 21:24

Re: Incompatible types: 'TMouseButton' and 'TGLMouseButton'
 
Das hab ich schon versucht:
Zitat:

[Error] formSpiel.pas(169): '[' expected but '.' found

Hawkeye219 11. Aug 2008 21:46

Re: Incompatible types: 'TMouseButton' and 'TGLMouseButton'
 
Hallo Dorian,

beim Versuch, eine Namensüberdeckung zu umgehen, bist du wahrscheinlich über die nächste gestolpert. Controls[] ist ein Array in TWinControl, das alle Controls enthält, die das WinControl als Parent haben.

Du könntest zunächst versuchen, die Reihenfolge der betroffenen Units (Controls und GLCrossPlatform) in der USES-Anweisung zu ändern. Möglicherweise führt diese Maßnahme aber zu anderen Fehlermeldungen.

Eine Lösung deines Problems könnte dann darin bestehen, außerhalb(!) der Methoden eine Konstante zu definieren und diese in der Methode zu verwenden:

Delphi-Quellcode:
const
  mb_Left = Controls.mbLeft;
 
procedure TSpiel.GLSceneViewer_SpielMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  //Konsole.Visible:= not Konsole.visible;
   case iModus of
      0:begin
        if Button = mb_Left then {linke maustaste}
        begin
[...]
Gruß Hawkeye

Pyr0cracker 11. Aug 2008 21:56

Re: Incompatible types: 'TMouseButton' and 'TGLMouseButton'
 
Danke Hawkeye, das war die Lösung.

Gruß,
Dorian


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:26 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz