Skip to content

Instantly share code, notes, and snippets.

@sorpdev
Forked from emmatyping/translucenttb.cpp
Created December 11, 2021 20:12
Show Gist options
  • Save sorpdev/d440ba7a562f8bc8409acaab2d99a53a to your computer and use it in GitHub Desktop.
Save sorpdev/d440ba7a562f8bc8409acaab2d99a53a to your computer and use it in GitHub Desktop.

Revisions

  1. @emmatyping emmatyping revised this gist Jan 9, 2017. 1 changed file with 0 additions and 19 deletions.
    19 changes: 0 additions & 19 deletions translucenttb.cpp
    Original file line number Diff line number Diff line change
    @@ -2,25 +2,6 @@



    LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    switch (msg)
    {
    case WM_NCHITTEST:
    wParam = DefWindowProc(hWnd, msg, wParam, lParam);
    if (wParam == HTCLIENT)
    return HTCAPTION;
    else
    return wParam;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hWnd, msg, wParam, lParam);
    }
    return 0;
    }


    void SetWindowBlur(HWND hWnd)
    {
  2. @emmatyping emmatyping created this gist Jan 9, 2017.
    66 changes: 66 additions & 0 deletions translucenttb.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    #include <windows.h>



    LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    switch (msg)
    {
    case WM_NCHITTEST:
    wParam = DefWindowProc(hWnd, msg, wParam, lParam);
    if (wParam == HTCLIENT)
    return HTCAPTION;
    else
    return wParam;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hWnd, msg, wParam, lParam);
    }
    return 0;
    }


    void SetWindowBlur(HWND hWnd)
    {
    const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
    if (hModule)
    {
    struct ACCENTPOLICY
    {
    int nAccentState;
    int nFlags;
    int nColor;
    int nAnimationId;
    };
    struct WINCOMPATTRDATA
    {
    int nAttribute;
    PVOID pData;
    ULONG ulDataSize;
    };
    typedef BOOL(WINAPI*pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*);
    const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hModule, "SetWindowCompositionAttribute");
    if (SetWindowCompositionAttribute)
    {
    ACCENTPOLICY policy = { 3, 0, 0, 0 }; // ACCENT_ENABLE_BLURBEHIND=3...
    WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; // WCA_ACCENT_POLICY=19
    SetWindowCompositionAttribute(hWnd, &data);
    }
    FreeLibrary(hModule);
    }
    }


    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
    {

    HWND taskbar = FindWindow(L"Shell_TrayWnd", NULL);


    while (true) {
    SetWindowBlur(taskbar); Sleep((DWORD)10);
    }

    }