Answered by:
Making a child window transperent

Question
-
Hi everyone,
Can anyone explain how we can make a child window transperant?
Regards,
leo
Wednesday, February 22, 2012 9:22 AM
Answers
-
This seems to be a ready-to-go extension for MFC. Quickly reading, it seems that the idea is to notify the child controls that the background is changing using a user-defined message.
I would imagine that it may also require that the child controls have the WS_EX_COMPOSITED extended window style, but that is just an assumption of mine.
Anyway, the process would be to update the control's background whenever the parent says so, then draw whatever else needs to be drawn.
But if what you want is a control with a non-rectangular shape, that can be obtained using SetWindowRgn().
Jose R. MCP
- Proposed as answer by Helen Zhao Monday, February 27, 2012 8:13 AM
- Marked as answer by Helen Zhao Thursday, March 1, 2012 1:26 AM
Wednesday, February 22, 2012 6:36 PM -
Hi leo,
According to the MSDN document, the third parameter of SetLayeredWindowAttributes function is used to describe the opacity of the layered windows. When it is 0, the window is completely transparent. When it is 255, the window is opaque. Perhaps you can find some ideas from it.
What's more, you can refer to the following links for more information about transparent child window:
Making a Transparent MDI Parent Form: http://www.codeproject.com/Articles/54844/Making-a-Transparent-MDI-Parent-Form.
StyleDialog - A transparent dialog class with an optional custom frame: http://www.codeproject.com/Articles/28336/StyleDialog-A-transparent-dialog-class-with-an-opt.
Transparent Child Window: http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesnative/thread/dce69339-f751-4a42-90d1-5d24f5f57e70.Have a nice day!
Helen Zhao
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by Helen Zhao Monday, February 27, 2012 8:13 AM
- Edited by Helen Zhao Thursday, March 1, 2012 1:26 AM
- Marked as answer by Helen Zhao Thursday, March 1, 2012 1:27 AM
Friday, February 24, 2012 6:14 AM
All replies
-
This seems to be a ready-to-go extension for MFC. Quickly reading, it seems that the idea is to notify the child controls that the background is changing using a user-defined message.
I would imagine that it may also require that the child controls have the WS_EX_COMPOSITED extended window style, but that is just an assumption of mine.
Anyway, the process would be to update the control's background whenever the parent says so, then draw whatever else needs to be drawn.
But if what you want is a control with a non-rectangular shape, that can be obtained using SetWindowRgn().
Jose R. MCP
- Proposed as answer by Helen Zhao Monday, February 27, 2012 8:13 AM
- Marked as answer by Helen Zhao Thursday, March 1, 2012 1:26 AM
Wednesday, February 22, 2012 6:36 PM -
Hi leo,
According to the MSDN document, the third parameter of SetLayeredWindowAttributes function is used to describe the opacity of the layered windows. When it is 0, the window is completely transparent. When it is 255, the window is opaque. Perhaps you can find some ideas from it.
What's more, you can refer to the following links for more information about transparent child window:
Making a Transparent MDI Parent Form: http://www.codeproject.com/Articles/54844/Making-a-Transparent-MDI-Parent-Form.
StyleDialog - A transparent dialog class with an optional custom frame: http://www.codeproject.com/Articles/28336/StyleDialog-A-transparent-dialog-class-with-an-opt.
Transparent Child Window: http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesnative/thread/dce69339-f751-4a42-90d1-5d24f5f57e70.Have a nice day!
Helen Zhao
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by Helen Zhao Monday, February 27, 2012 8:13 AM
- Edited by Helen Zhao Thursday, March 1, 2012 1:26 AM
- Marked as answer by Helen Zhao Thursday, March 1, 2012 1:27 AM
Friday, February 24, 2012 6:14 AM -
Layered windows cannot be child windows. See http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx. This is why I didn't mention it.
Jose R. MCP
Friday, February 24, 2012 1:29 PM