Unable to set Parent Object RRS feed

  • Question

  • Hi,

    I am facing an issue in setting an Application (Mainframe Emulator - Rweb) as a child of another Win 32 form.

    The following code is used to set the Parent Form:

    Win32.SetParent((IntPtr)hWnd, parent.Handle)

    This is method is working fine when executed first time. However, once the child Application has been undocked from Parent Form, the above mentioned code is not working.

    The Win32 Application freezes and crashes on executing the above mentioned code.

    Any help in resolving this issue would be appreciated.

    • Moved by Stanly Fan Friday, March 2, 2018 1:06 AM
    Tuesday, February 6, 2018 11:48 AM

All replies

  • Hi,

    I'm afraid you need to check how did you set the parameters for the SetParent() method in your project, to check if there is a possibility to set it to NULL, you can find there are some descriptions about SetParent() method that say:

    Conversely, if hWndNewParent is not NULL and the window was previously a child of the desktop, you should clear the WS_POPUP style and set the WS_CHILD style before calling SetParent.

    Refer: SetParent function.

    And check after undock, if the parent windows is the original or return to the desktop.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 7, 2018 7:32 AM