1,105,399 Community Members

Event handler for dynamically created panel

Member Avatar
maglarp
Newbie Poster
3 posts since May 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

How do I specify a mouseDown eventhandler to dynaically creted Tpanels? My intention is to create a number of panels, like tiles, and move them around on the Form
I have created a design time TPanel and copied its OnMouseDown event and saved it as PanelMouseDown.
My code:

Pan:=TPanel.Create(Form2);
Pan.Height:=60;
Pan.Width:=60;
Pan.Parent:=Form2;
Pan.DragMode:=dmManual;
Pan.OnMouseDown :=Form2.PanelMouseDown;

I cant get the panels to react on mouseclicks. Does somebody have any suggestions?

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

That code looks okay. What's in the event handler? What happens when you step through it with the debugger?

Member Avatar
maglarp
Newbie Poster
3 posts since May 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Event handler never get trigged. Code for the moment is only beep;

Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

Show the event handler.

Question Answered as of 11 Months Ago by pritaeas
Member Avatar
maglarp
Newbie Poster
3 posts since May 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
1
 

Sorry bothering you all! I had put a label over the panel and the label covered the whole Panel so the Label was clicked instead of the Panel. Increasing the panel and clicking outside the label all worked well and the cration cod for the panel was correct. Thanks pritaeas for your engagement. Case closed.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: