locked
change parent window to desktop RRS feed

  • Question

  • Hi,

    I am developing an MFC app in Visual studio 12. I have created a child window but would like the parent window to be the desktop so I can move the window about, in a similar manner as a modeless dialog. I do not know how to do this can someone help please?

    Wednesday, December 18, 2013 4:35 PM

Answers

All replies

  • Hi,

    According to your description, you want to change the parent window of the specified child window to desktop. If my understanding is right, I would suggest you to use GetDesktopWindow function to retrieve a handle to the desktop window, then use SetParent function to change the parent window of the specified child window.

    Hope this can help you, if you have any problems, please don't hesitate to let me know.

    Best Wishes,

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Bordon Thursday, December 19, 2013 5:32 AM
    • Marked as answer by May Wang - MSFT Tuesday, December 31, 2013 1:57 AM
    • Unmarked as answer by May Wang - MSFT Tuesday, December 31, 2013 3:15 AM
    Thursday, December 19, 2013 1:33 AM
  • Thanks May, but it has caused an asertion error at:

    f:\dd\vctools\vc7libs\atlmfc\src\mfc\objcore.cpp line 40

    Thursday, December 19, 2013 1:15 PM
  • I put it in a different location and it works but not as I thought it would work.

    Thanks

    Thursday, December 19, 2013 6:06 PM
  • You really don't want to parent a child window to GetDesktopWindow (see http://blogs.msdn.com/b/oldnewthing/archive/2004/02/24/79212.aspx )

    A modeless dialog isn't a child (WS_CHILD) window. You should create your window as an overlapped or popup window (see Window Styles ) to have a window which can move around arbitrarily. See Window Types .

    --Rob

    Thursday, December 19, 2013 11:21 PM
  • Thanks May, but it has caused an asertion error at:

    f:\dd\vctools\vc7libs\atlmfc\src\mfc\objcore.cpp line 40

    Hi Rockmate,

    Thank you for your feedback.

    I don't know how you wrote the codes and where you put the codes. If you need further help, you can provide some code snippets or screen shot here for us.

    In addition, you said that "I put it in a different location and it works but not as I thought it would work." What is your expectation?

    If the dialog is modeless, please take advice from Rob. I have already marked the answer for you, if your target is not like this, you can unmark and provide more information. Thanks for your understanding.

    Best wishes,

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, December 20, 2013 3:17 AM