Strange Behavior of OnRemoveDControl

Hi all

I prevent removing blocks if they are still connected to
lines. I add in the event handler of OnSelectDControl crNoDelete to
Restrictions as Wagner told me (Thanks!).
If the user press x to remove the block, the block isn't removed because crNoDelete is set.
But when I try to show a message in the event handler of OnRemoveDControl, the message is not shown:
// I use C++ Builder

if (ADControl->Restrictions.Contains(crNoDelete)) {
     ShowMessage("Connected elements cannot deleted!\nPlease delete all connections first!");
     ADControl->Restrictions >> crNoDelete;
   } 
=> no message box! But when I click "Undo" the message box is shown.
Is there a workaround?

Thanks!

It seems that OnRemoveDControl is not fired if crNoDelete is set.
But then I see no possibility to inform the user why it's not possible to remove the block.
Any idea?

Unfortunately there is no such possibility to hook a "before-delete-but-after-click" event.

You could just use a different button and do it yourself, or display the undeletable controls in a different way (different color, etc.)

Thanks Wagner,

I already tried it with a separate button. That works but I have
problems to position the button exactly in the same height as the
toolbar. I put both on a TPanel, button with Left alignment and toolbar
with Client alignment but there is always a shift of 1 or 2 pixels. But my expectations may be too high !!