# Moving objects between frames in VB6



## lamstaldy (Dec 16, 2001)

Is it possible to move an object from one frame to another at runtime? I have six ActiveX components that use winsock connections to get images from six different cameras. I currently have three frames on a form, each frame has two of the images displayed in 1/8 size. I'd like to be able to display any one of the images in 1/4 size, along with more details about the image. The easiest way I can see to do this would be to have another six frames all setup and just make them visible when I need them, but I need to move the ActiveX object from the original frame to the new one. Is this possible?


----------



## Aftab (Oct 15, 2003)

This is the API function you will need:

Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

I tested this with two frames on a form (Frame1 and Frame2), placed a combo box inside frame2 and a command button on the form, then placed the following code in the click event of the command button:

Private Sub Command1_Click()
SetParent Combo1.hWnd, Frame1.hWnd
End Sub

See how you get on with that.


----------

