I'm trying to change the color of a panel on Lazarus on mouse hover.
I try run this code on Lazarus:
unit test;
{$mode objfpc}{$H+}
interface
uses
[...]
type
{ Tvendas_menu }
Tvendas_menu = class(TForm)
[...]
procedure StartMouseEnter(Sender: TObject);
[...]
private
{ private declarations }
public
{ public declarations }
end;
var
[...]
implementation
[...]
procedure Tvendas_menu.StartMouseEnter(Sender: TObject);
begin
Start.Color := $00E7E7E7;
end;
[...]
But when compiling the program show the following error code:
Error: Identifier not found "Start"
I'm sure that "Start" is the name of the panel on Object Inspector and .lfm file.
I try to change "Start" to another name but the error still occurs.
Thanks!
When you add controls to the form they automagically get added under the form class, in your case they would appear under Tvendas_menu = class(TForm)
.
One possibility of the error could be because the line Start
is missing, you should have something like:
type
Tvendas_menu = class(TForm)
Start: TPanel;
private
{ Private declarations }
public
{ Public declarations }
end;
To resolve this, try adding the line Start: TPanel;
like above if it is not present.
One other option you have is to view the form in text view (.lfm
for Lazarus and .dfm
for Delphi) and find the reference block for Start
, it may look something like:
object Start: TPanel
Left = 152
Top = 248
Width = 185
Height = 41
Caption = 'Start'
TabOrder = 1
end
Delete that and then return back to Form view.
Then you can try adding a new panel to the form and naming it Start
, then you just need to link your event handlers back to the new control.
As a side tip, naming a control Start
is not really very useful, maybe think of a better named identifier such as panStart
.