How to get a control under a different control?

I am trying to create a basic entertainment map editor that consists of scrollbox and paintbox (for drawing a grid).

In the OnMouseDown event for paintbox, I create images at runtime and add them inside the scroll, the mesh paint is painted over the images (because if the grid was on the back, it would just look nice).

Here is an example screen:

enter image description here

My question will solve two of my problems in one.

  • I need to be able to drag and drop images around at runtime.
  • I also need to be able to display the X and Y positions of the image as information.

That's where my problem is, to solve the problems above, I first need to get the image under the mouse cursor. But since I draw my paintbox over the images, the cursor will only “see” the paint grid, not the main images.

I experimented with copying the paintbox grid in TImage, but it all went wrong and I had errors in memory. The size of the cards can be quite large, so placing the grid in a bitmap is not ideal due to memory and limitations, etc.

The grid should go on top, otherwise it will look something like this:

enter image description here

What hides the grid, and I don't want this to happen.

So, how can I see the past color and go to the images below them using FindVCLWindow or something similar?

+6
source share
1 answer

Set the Enabled PaintBox property to False . This will skip mouse messages.

Further:

In the OnMouseDown event for PaintBox, I create images at runtime and add them inside the scroll

Change this to the OnMouseDown event on a ScrollBox. Set the coordinates to ScrollBox.[Horz/Vert]Scrollbar.Position .

+7
source

Source: https://habr.com/ru/post/954369/


All Articles