[ACXFAQ018]
How do I set the parent of an ActiveX component in Visual Basic or Visual C++?


Here is some sample code showing how to set the parent of one of our ActiveX Components to the iPanelX control...

Visual Basic 6 Example

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

Private Sub Command1_Click()
  'Set the parent of the Tank to the Panel Component
  SetParent iTankX1.ComponentHandle, iPanelX1.ComponentHandle
End Sub
Visual C++ 6 Example
void CProject1View::OnButton1()
{
  :: SetParent(m_iTankX1.m_hWnd, m_iPanelX1.m_hWnd);
}

Copyright ©1998-2007 Iocomp Software Incorporated. Iocomp and the Iocomp Logo are registered trademarks of Iocomp Software Inc. All other trademarks are registered by their respective owners.