Frage

I am trying to create a basic map editor for fun which consists of a scrollbox and paintbox (to draw the grid).

In the OnMouseDown event for the paintbox I create images at runtime and add them inside the scrollbox, the grid paintbox is painted above the images ( because if the grid was at the back it just would not look good ).

Here is a sample screen:

enter image description here

My question would solve two of my problems in one.

  • I need to be able to drag and drop (to move) the images around at runtime.
  • I also need to be able to get the X and Y position of the image to display as information.

Here is where my problem lies, to solve the problems above I first need to get the Image under the mouse cursor. But because I paint my grid (paintbox) above the images, the cursor will only ever 'see' the paintbox grid, and not the underlying images.

I did experiment with copying the paintbox grid to a TImage but it came out all wrong and I was getting out of memory errors. The size of the maps could be quite large and so putting the grid onto a bitmap is not ideal due the memory and limitations etc.

The grid must go on the top, otherwise it would look something like this:

enter image description here

Which hides the grid, and I don't want that to happen.

So, how can I see past the paintbox and get to the images underneath, using FindVCLWindow or something similar?

War es hilfreich?

Lösung

Set the Enabled property of the PaintBox to False. That will let the mouse messages go through.

Further:

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

Change that to the OnMouseDown event on the ScrollBox. Adjust the coordinates by ScrollBox.[Horz/Vert]Scrollbar.Position.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top