Recent

Author Topic: [solved]Dynamic created TImages stop responding to @Image1MouseDown  (Read 1797 times)

dcom67

  • New Member
  • *
  • Posts: 14
 I have 256 dynamically created Timage controls.  They all show up fine , But after the 232 one they stop responding to the @Image1MouseDown event.

The same result if the event is changed to Im.OnCLick:=@Image1Click;

Any Ideas ?

IML : TObjectList;
Code: Pascal  [Select][+][-]
  1.              IM:=TImage.Create(Self);
  2.              IM.Name:='IM'+IntToStr(a);
  3.              IM.Left:=(ScrollBox1.ClientWidth  div 2) -((w *24) div 2)-20;
  4.              if b = 0 then IM.Top:= 0  else
  5.                begin
  6.                  I:=IML.Items[IML.Count-1] as TImage;
  7.                  IM.Top:=( I.Top +I.Height +22);
  8.                end;
  9.              IM.Width:=(w *24) *2;
  10.              IM.Height := (h*24)*2;
  11.              Panel2.Height:=Panel2.Height+ IM.Height+1;
  12.              IM.Stretch:= True;
  13.              IM.OnMouseDown:=@Image1MouseDown;
  14.              IM.Tag := a;
  15.              IML.Add(IM);
  16.              IM.Picture.LoadFromFile(TempDir+sa[0]+EPNG);
  17.              Im.Transparent:= True;
  18.              Im.Picture.Bitmap.TransparentMode:=tmfixed;
  19.              IM.picture.bitmap.Transparent:=True;
  20.              IM.Picture.Bitmap.TransparentColor:=$000000;
  21.              IM.Parent:= Panel2;
  22.  
  23.  



« Last Edit: September 16, 2021, 04:59:53 pm by dcom67 »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7434
  • Debugger - SynEdit - and more
    • wiki
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #1 on: September 15, 2021, 09:28:39 pm »
OS, Widgetset?


P.s.: Edited your post to remove tons of empty lines :)

dcom67

  • New Member
  • *
  • Posts: 14
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #2 on: September 15, 2021, 09:52:24 pm »
Oh it is Win10  .

Sorry didn't see all of those empty lines :)

jamie

  • Hero Member
  • *****
  • Posts: 4907
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #3 on: September 16, 2021, 01:50:24 am »
I would say you hit a limit with the number of TGraphicControl class a parent window can have.
256 sounds like a byte size limit.

You must have some other TGraphicControl classes also assigned to the same parent.

 Maybe you should rethink your design a little where as you use a single parent control and you then calculate the mouse locations to which image they should go to..

 A TDrawGrid is a good control for this..

The only true wisdom is knowing you know nothing

dcom67

  • New Member
  • *
  • Posts: 14
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #4 on: September 16, 2021, 02:26:36 am »
Yeah i was kind of afraid of that, but why do they show up and the event stops working ?

The only other thing on the panel2 parent is a Tlabel for each image.

I was kind of hoping to keep it looking like a list of images.

And i have never used a TDrawGrid before. :)

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1005
    • Lebeau Software
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #5 on: September 16, 2021, 02:28:42 am »
I would say you hit a limit with the number of TGraphicControl class a parent window can have.
256 sounds like a byte size limit.

There should be no such limitation.

Maybe you should rethink your design a little where as you use a single parent control and you then calculate the mouse locations to which image they should go to..

A TDrawGrid is a good control for this..

I was thinking a TPaintBox.

Yeah i was kind of afraid of that, but why do they show up and the event stops working ?

Have you tried stepping through the LCL's source code to see where those mouse clicks are actually going?
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

dcom67

  • New Member
  • *
  • Posts: 14
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #6 on: September 16, 2021, 02:40:25 am »
I set a BreakPoint in the mouse down event

Yes they don't do anything for the mouse clicks ( for the ones that don't work)  all of the others activate the mouse down event as expected
« Last Edit: September 16, 2021, 02:44:15 am by dcom67 »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1005
    • Lebeau Software
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #7 on: September 16, 2021, 02:46:58 am »
Yes they don't do anything for the mouse clicks ( for the ones that don't work)  all of the others activate the mouse down event as expected

My point was, at the moment that the click enters the underlying system (ie, the message queue reports a WM_MOUSEDOWN message), did you trace its handling from cradle to grave to see exactly where it is stopping in the LCL's code before it reaches your event handler?  Maybe the LCL is not able to correctly determine the control that the message belongs to, so it drops the message? Hard to say without a deep tracing of the LCL internals.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

dcom67

  • New Member
  • *
  • Posts: 14
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #8 on: September 16, 2021, 02:50:30 am »
Uh that is kind of beyond me. I only know how to set a breakpoint in my code

dcom67

  • New Member
  • *
  • Posts: 14
Re: Dynamic created TImages stop responding to @Image1MouseDown
« Reply #9 on: September 16, 2021, 04:58:50 pm »
  I fixed it :)

I added a second panel , and added the second panel as the parent above 200 images.
« Last Edit: September 16, 2021, 05:03:02 pm by dcom67 »

 

TinyPortal © 2005-2018