Recent

Author Topic: A property missing (MouseMove)  (Read 4490 times)

Peiman

  • New Member
  • *
  • Posts: 41
A property missing (MouseMove)
« on: June 21, 2010, 10:53:01 am »
Hi.

I have a same definition of custom graphics for two projects. While one is compiled easily the other raises the "unknown identifier" error.

both of them are nearly like below
Quote
type
  TStyleCanvas = class(TCustomControl)
  public
    SRC : HDC;
    procedure EraseBackground(DC: HDC); override;
    procedure Paint; override;
  end;
 ...
var
  StCan : TStyleCanvas;
...
stCan.OnMouseMove := @MMove;
...
In one of the project it says that "OnMouseMove" is an unknown identifier while in the other no such error.
The only difference is that in the error-giving project the TStyleCanvas is defined in another unit, while in the running project it is define in the main unit. I think this is the problem. but, Why?
The mousemove event path : TControl > TWinControl > TCustomControl

Does anyone know what the problem is?

Thank u.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: A property missing (MouseMove)
« Reply #1 on: June 21, 2010, 12:13:29 pm »
It's protected in TControl. Do this in your TStyleCanvas:

Code: [Select]
type
  TStyleCanvas = class(TCustomControl)
  public
    SRC : HDC;
    procedure EraseBackground(DC: HDC); override;
    procedure Paint; override;
  published
    property OnMouseMove; //<-raise to published
  end;

Peiman

  • New Member
  • *
  • Posts: 41
Re: A property missing (MouseMove)
« Reply #2 on: June 21, 2010, 11:46:40 pm »
Thank u.
It worked.
But, as I said, the definition of the both "TStyleCanvas"es were the same. I mean none of them had "published". So , why one of them worked without this declaration while the other didn't? Was there any compiler option for that?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: A property missing (MouseMove)
« Reply #3 on: June 22, 2010, 12:35:26 am »
Classes in the same unit can access protected and private methods and variables of each other. It has always been this way in Delphi too.