Einzelnen Beitrag anzeigen

Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.343 Beiträge
 
Delphi 11 Alexandria
 
#6

Re: Maus-transparente Komponente

  Alt 27. Mär 2008, 10:48
Ich weiß noch nicht recht, was Du genau meinst.
Die TLine funktioniert so:

Delphi-Quellcode:
  TLine = class(TPaintBox)
  private
    FLineMode: TLineMode;
    FFromX: Integer;
    FFromY: Integer;
    FToX: Integer;
    FToY: Integer;
  protected
    procedure SetLineMode(const Value: TLineMode);
    procedure SetFromX(const Value: Integer);
    procedure SetToX(const Value: Integer);
    procedure SetFromY(const Value: Integer);
    procedure SetToY(const Value: Integer);
    procedure Paint; override;
    procedure CMHitTest(var Msg: TWMMouse); message CM_HITTEST;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure SetPosition(X1, Y1, X2, Y2: Integer); virtual;
    procedure SetPositionTo(X, Y: Integer); virtual;
    procedure DefineStyle; virtual;
  published
    property LineMode: TLineMode read FLineMode write SetLineMode;
    property FromX: Integer read FFromX write SetFromX;
    property FromY: Integer read FFromY write SetFromY;
    property ToX: Integer read FToX write SetToX;
    property ToY: Integer read FToY write SetToY;
  end;

...

{ TLine }

procedure TLine.CMHitTest(var Msg: TWMMouse);
begin
  inherited;
{
  if Assigned(PicUp) and Assigned(PicUp.Bitmap) and Transparent and
    (Msg.XPos < PicUp.Bitmap.Width) and (Msg.YPos < PicUp.Bitmap.Height) and
    (PicUp.Bitmap.Canvas.Pixels[Msg.XPos, Msg.YPos] = (Picture.Bitmap.TransparentColor and $FFFFFF)) then
    Msg.Result := 0;
}

  Msg.Result := 0;
end;

Für meine Panelableitung habe ich das genau so geregelt:
Delphi-Quellcode:
  TPanelHead = class(TPanel)
  private
  protected
    procedure CMHitTest(var Msg: TWMMouse); message CM_HITTEST;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

...

{ TPanelHead }

procedure TPanelHead.CMHitTest(var Msg: TWMMouse);
begin
  beep; // HIER GEHT NIX
  inherited;
{
  if Assigned(PicUp) and Assigned(PicUp.Bitmap) and Transparent and
    (Msg.XPos < PicUp.Bitmap.Width) and (Msg.YPos < PicUp.Bitmap.Height) and
    (PicUp.Bitmap.Canvas.Pixels[Msg.XPos, Msg.YPos] = (Picture.Bitmap.TransparentColor and $FFFFFF)) then
    Msg.Result := 0;
}

  Msg.Result := 0;
end;
Hier wird CMHitTest aber nicht erreicht...
  Mit Zitat antworten Zitat