Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 4, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Problems With ActiveX Controls Pasted From Clipboard

In VB5, the event is not called when an instance of your UserControl is copied into the clipboard and pasted again, creating a new one. This affects user controls that depend on the UserControl_Resize event to define the control's appearance. To check this behavior, start VB5, create a new ActiveX Control project, and add a text box in the middle of your UserControl area. Add this code to the UserControl Resize Event:
Private Sub UserControl_Resize()
        Text1.Move 0, 0, Width, Height
End Sub
Close your UserControl and add a Standard EXE project. Create an instance of your new UserControl. You should get a text box filling all your UserControl area. Now copy the UserControl to the clipboard and choose Paste. Note the new instance of your control doesn't resize the text box as it should. To work around this problem, add this code to the UserControl ReadProperties event:
Sub UserControl_ReadProperties_
        (PropBag As PropertyBag)
        Call UserControl_Resize
End Sub
Miguel Santos
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date