Differences between OnInsertBlock and OnInsertDControl when inserting/creating a block

Hello,

When I insert a block, there are differences for at least 2 properties with OnInsertBlock and OnInsertDControl depending on whether the block is inserted (from the toolbar or by program).

From the toolbar :

I can access the name (automatically generated) of the block in the event OnInsertBlock. It remains in the event OnInsertDControl.

By program :

I can't access the name of the block in the event OnInsertBlock (name is empty). I can access the name (automatically generated) in the event OnInsertDControl.

If I set the LayerName just after creating the block and assigning it to the diagram, I can get it in neither of the 2 events (but the LayerName is set).

For both :

If I set the LayerName of the block in the event OnInsertBlock, it disappears : LayerName is empty in the event OnInsertDControl.

If I set the LayerName of the block in the event OnInsertDControl, it's OK.

Could you shed some light on those behaviors?

It's a simple explanation, OnInsertBlock event is called before OnInsertDControl event. Between both calls, the layer mechanism is processed, thus modifications regarding that can happen.

OnInsertDControl is the generic one and should be enough for all operations. If you need block operations, just check if the inserted control is a TCustomDiagramBlock, cast to it and perform the needed block-related operations.

OK, thanks.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.