javajavafxwindows-10glfwtaskbar

How to hide by code Windows 10 window's icon on task bar


To display OpenGL with a Java application that uses JavaFx, I use a GLFW window that is positioned behind a transparent area of my application. This gives the illusion that OpenGL views are part of the application.

Under Windows 10, this GLFW window is visible and selectable in the taskbar, which short-circuits its enslavement by the application and makes it out of control :

enter image description here

I imagine that it is possible by code (I am considering in C via the JNI) to hide in the taskbar this GLFW window (whose window handle is given) but I am not sure what must be accessed in the bowels of the Windows OS.

If anyone has an idea or can guide me on which part I need to document.


Solution

  • Have a look at the Managing Taskbar Buttons paragraph : https://learn.microsoft.com/en-us/windows/win32/shell/taskbar

    This is the solution i managed to find dealing with a similar issue in c++ just now. Obviously you need access to the win32 api. This is what you need to have happen to your GLFWWindow* win variable to hide it's taskbar entry:

    {   /* signal not appear on task bar */
        auto hwnd = glfwGetWin32Window(win);
        ShowWindow(hwnd, SW_HIDE);
        SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
        ShowWindow(hwnd, SW_SHOW);
    }
    

    SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); is what does it. The paragraph also mentions using window ownership to hide the task bar icons of windows which might be more what you're looking for but i haven't looked into that. You should be able to use JNI to call the right functions. So you might make a dll out of something like this (note i don't use java much so take this as a starting point):

    #define GLFW_EXPOSE_NATIVE_WIN32
    #include <GLFW/glfw3.h>
    #include <GLFW/glfw3native.h>
    
    __declspec( dllexport ) void hide_taskbar_icon(GLFWWindow* win)
    {
        glfwHideWindow(win);
        SetWindowLong(glfwGetWin32Window(win), GWL_EXSTYLE, WS_EX_TOOLWINDOW);
        glfwShowWindow(win);
    }
    

    That's the best i got from my side good luck.