Can I remove only the title bar?

Can I remove only the title bar but keep the borders?

SDL2 does not natively support removing only the title bar while keeping the borders. When you use the SDL_WINDOW_BORDERLESS flag, all decorations, including the title bar and borders, are removed.

If you need this functionality, you'll need to use platform-specific APIs to modify the window style directly. For example, on Windows, you could use the Win32 API to customize the WS_BORDER and WS_CAPTION flags of the window.

However, this approach bypasses SDL2's abstraction and ties your code to a specific platform.

Here's an example of creating a completely borderless window in SDL2 (no title bar or borders):

#include <SDL.h>

int main() {
  SDL_Init(SDL_INIT_VIDEO);

  SDL_Window* Window{SDL_CreateWindow(
    "No Title Bar",
    SDL_WINDOWPOS_CENTERED,
    SDL_WINDOWPOS_CENTERED,
    800, 600,
    SDL_WINDOW_BORDERLESS 
  )};

  SDL_Delay(3000);
  SDL_DestroyWindow(Window);
  SDL_Quit();
}

To keep the borders but remove the title bar, a workaround is to simulate borders using custom rendering inside the client area. Alternatively, look into platform-specific APIs if this functionality is critical.

Window Decorations and Borders

An introduction to managing SDL2 window decorations, borders, and client areas.

Questions & Answers

Answers are generated by AI models and may not have been reviewed. Be mindful when running any code on your device.

Why use a borderless window?
Why would you want a borderless window in an application?
Can SDL customize border colors?
Can I change the color of the border or title bar in SDL2?
Borderless and SDL_GetWindowBordersSize()
How does SDL_GetWindowBordersSize() behave on borderless windows?
Uses of window decoration sizes
What are some practical uses for knowing the size of window decorations?
Resizable borderless windows in SDL2
Can I create a borderless window that still has a resizable frame?
Decorations in fullscreen modes
How do window decorations affect fullscreen modes?
Customizing window decorations
How can I customize window decorations in SDL2?
Or Ask your Own Question
Get an immediate answer to your specific question using our AI assistant