0

I developed a tool to be transparent on a window in Windows 10, using WINAPI, SetWindowLong, SetLayeredWindowAttributes and LWA_COLORKEY (C++). It can work on any window, however, it cannot work on web browsers. I found a same case,

Winapi - How to achieve equivalent of LWA_COLORKEY for MS Edge browser

SetLayeredWindowAttributes to make a window transparent is only working part of the time

and it can work on browsers not using hardware acceleration option. But, the actions on browsers are slow because of not using the hardware acceleration.

Is there another way to be transparent on a window? ( Can it work using Direct3D programing? and how?)

rev_max
  • 3
  • 1

1 Answers1

-1

Have you checked the Rita Han's reply: https://stackoverflow.com/a/61768293

I have tested the code. It can work on web browsers.

enter image description here

Here is the code:

#include <iostream>
#include <Windows.h>

int main(int argc, char* argv[])
{
       HWND hwnd = (HWND)0x0005059C;// The handel of the web browser window
        if (!SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED))
            printf("SetWindowLong error: %d\n", GetLastError());
        if (!SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 50, LWA_COLORKEY))
            printf("SetLayeredWindowAttributes error: %d\n", GetLastError());
}
Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20
  • Thank you for your comment. I'm sorry that my explanation is not sufficient. My tool can work using WINAPI like the code, if I switch OFF the hardware acceleration of setting of browsers. If the switch of the hardware acceleration is on, it cannot work. Is there a way to use the hardware acceleration and transparent? – rev_max Jan 16 '23 at 09:14
  • 2
    If the question already has an answer then it should be closed as a duplicate. Reposting code from a different answer is not how Stack Overflow works. But that is moot since this proposed answer doesn't actually answer the question at all. You cannot magically turn a DirectX surface translucent by mucking with window styles. – IInspectable Jan 16 '23 at 13:35