Controls and the Clipboard

Another common bug with ActiveX Controls is when they are copied and pasted using the clipboard. A simple way to ensure the mechanism is working for your control is to create a new form, copy the control to the clipboard, and then paste the control back to the form. Next, select both controls, copy them to the clipboard, and paste them back. Also, try pasting the controls using PasteSpecial as each type that is listed in the dialog. Be aware that you will get an error, "You can’t paste the object as the type specified," if you have written the control using the BaseCtl framework and have not implemented the IDataObject interface. The PasteSpecial as the other two types available will work however. If you are developing your control using VB 5.0 or MFC, the framework supplies a default implementation of this for you.

PasteSpecial as type picture is often missed (or omitted) by many control developers, but can leave a rather unattractive white rectangle on the form or report. This is not terribly important if the control is not going to be used in this fashion. However, I believe this is the same code that is responsible for many controls looking unprofessional when print previewed since the metafile representation of the control is used, so it may be worth while to add it. This is discussed later in this document.

It’s also interesting to try using Edit | Undo after a paste of multiple controls, as well as after the other operations listed above.