Transparent hwnd window

前端 未结 2 1332
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 12:28

Is it possible to create a \"transparent\" hwnd window ? What I mean by that is that there is no background or borders of that window but that only text is visible...like if

2条回答
  •  抹茶落季
    2021-01-07 12:44

    On Windows 2000 and later, you can create a top-level window with the WS_EX_LAYERED style (on Windows 8 and later, child windows can now use the WS_EX_LAYERED style as well), and then use SetLayeredWindowAttributes() or UpdateLayeredWindow() to make the window transparent.

    Create a solid background color, and then set that color as the window's transparent color. Anything on the window that is not using that color will not be transparent. The OS will handle the rest for you.

    Refer to MSDN for more details:

    • Layered Windows
    • Using Layered Windows
    • SetLayeredWindowAttributes()
    • UpdateLayeredWindow()

提交回复
热议问题