GetControlAtMouse for child controls? lazarus / 31-LCL ---------------------------------------------------------------------- ned_flanders · 2013-09-22 18:29 I have a TScrollBox and inside it I have a TPaintBox (to draw a grid). At runtime I am adding images (TImage) as a child to the TScrollBox , which are drawn under the TPaintBox. What I would like is to be able to get the name of the images under the cursor that are inside the TScrollBox, but am unsure how to do this. I looked for Delphi answers and they suggest FindVCL window, the alternative for Lazarus I think could be Application.GetControlAtMouse? How can I retrieve the images that lie beneath the TPaintBox, which is child to the TScrollBox ? TScrollBox > TPaintBox > TImage The images must be drawn beneath the grid, which could make this trickier but the grid must be on top of the images. This is the code I modified from: http://delphi.about.com/od/delphitips2008/qt/find-vcl-window.htm Code: [Select]procedure TMainForm.PaintBoxMouseMove(Sender: TObject; Shift: TShiftState;   X, Y: Integer);  var   Ctrl: TControl; begin    Ctrl := Application.GetControlAtMouse;   if Ctrl <> nil then   begin     if Ctrl is TImage then     begin       Caption := TImage(Ctrl).Name;      end;   end; end; Thanks. ---------------------------------------------------------------------- howardpc · 2013-09-22 22:04 I suggest you explore the TDrawGrid component which integrates a grid with scrolling functionality, and provides an OnDrawCell event property where you can display each image. You can use one of the other provided events (say OnSelection) to set the Hint for the selected cell to show the name of the image it contains (set ShowHint to True). ---------------------------------------------------------------------- ned_flanders · 2013-09-23 09:32 Will do thanks howardpc