none
user32.dll detach or unhook to SetParent RRS feed

  • Question

  • I have the following code that takes a child window and separates it from the parent MDI Form window, and it works for me, the window separates from the MDI Form, but I need to do the opposite that the child window returns to its original place in the MDI Form, How can I do that? Here I leave the code, thank you very much for your help in advance

    #import "user32.dll"  

    ........

          SetParent(hwnd,NULL);

          int style = GetWindowLongA(hwnd, GWL_STYLE);
          style = style & (0xffffffff-WS_CHILD);
          style = style | WS_CAPTION | WS_OVERLAPPED | WS_THICKFRAME | WS_TILED | WM_CONTEXTMENU;
          style = style | WS_BORDER | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX | WM_MDIACTIVATE;
          
          SetWindowLongA(hwnd, GWL_STYLE, style);
          SetWindowPos(hwnd, HWND_TOPMOST,0,0,0,0,0x0027);
          EnableWindow(hwnd,true); 



    Edchar

    Tuesday, November 26, 2019 6:21 PM

All replies

  • Hi Edchari,
    I viewed your description and couldn't understand what the original place of child window is.
    According to the description, it works for you that separates the child window from the parent MDI Form window.
    So, could you please explain it in detail. And what is your requirement?
    Best Regards,
    Daniel Zhang


    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, November 27, 2019 6:04 AM
  • Thanks for answering Daniel Zhang, correct I have an MDI window with several windows inside it, seberal child windows, I using SetParent from User32.dll can separate the window from the MDI, that is, it behaves like a popup windows or standalond windows outside the MDI, but I don't know what code can make that window return to the internal position of the MDI, as it was original that it was a Child window.

    Now if you have a better example than the one I'm using, to do that, but with the User32 DLL I appreciate you helping me with that

    Can You help me please

    Tanks to your Help

    Best Regards


    Edchar

    Thursday, November 28, 2019 12:19 PM
  • Hi Edchari,
    You can try to use the GetParent function, more details you can refer to Edgemeal’s answer.
    Best Regards,
    Daniel Zhang

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    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.


    Monday, December 2, 2019 3:14 AM