Code Monkey home page Code Monkey logo

borderless-window's Introduction

borderless-window

Many Windows applications choose to remove the system window borders on their main window. The naive way of doing this is to create a popup window (with the WS_POPUP style) instead of an overlapped window, however popup windows are more suited to things like splash screens and other overlays, not main application windows. They lack a number of useful behaviours such as window snapping and the window menu, so they can be frustrating for users who expect these behaviours.

The proper way to create a borderless application window is to create a regular overlapped window and remove the borders by expanding the client area. This is what Office, Visual Studio, iTunes and UWP CoreWindows do, however doing this exposes some quirks in the windowing system that must be worked around in each application.

borderless-window is a minimal demonstration of how to work around these quirks. It creates a window that:

  • Works with window snapping, including double-click to snap vertically
  • Works with Aero Flip 3D
  • Obeys the "minimize all" command (Win+M)
  • Obeys the cascade and tile commands
  • Shows a window menu when Alt+Space is pressed
  • Does not cover the taskbar when maximized
  • Does not disable auto-hide taskbars when maximized
  • Casts a drop-shadow, like other top-level windows
  • Has hide, show, maximize, minimize and restore animations, like other top-level windows
  • Can be resized by the user
  • Does not accumulate visual corruption in the client area from the hidden window borders when the window is activated, the window text is changed or the window menu is opened

Building

A Makefile is included for mingw-w64 GCC. The C source should also compile in Visual Studio 2015 with a recent Windows SDK. The generated binary should be compatible with Windows Vista and up. It will not work unmodified on Windows XP due to the hard dependency on dwmapi.dll.

Copying

This project is a demonstration of something simple that is made unnecessarily difficult by quirks in the Windows API. In order to be as useful as possible to as many application developers as possible, it is placed in the public domain. Attribution would be appreciated, but is not required (after all, this stuff should have been documented by Microsoft.)

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

CC0

borderless-window's People

Contributors

rossy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

borderless-window's Issues

Passing window data to the window procedure callback.

I'm trying to implement the core code in a custom WPF Window, but i've problems with the data communication.

In your code you pass the * Window structure via CreateWindowExW (lParam) - OK.
How do I do this, taking into account that I do not have access and can not make the call of this function?

If you can help me, I'll be very grateful. Thanks in advance.

Possibly better way of calculating maximized client rectangle

Hello! Thank you for this example, it helped me a lot.

After experimenting a bit, I think I found a better way of calculating the bounding rectangle of the non-client area in WM_NCCALCSIZE. Firstly, add the WS_MAXIMIZEBOX style flag to the window. This enables it to maximize when dragging it towards an edge of the monitor (size snapping), but it also makes the bottom of the window not get obscured by the taskbar. This makes the hacky solution with has_autohide_appbar unnecessary (the shell won't make it full-screen).

In my WM_NCCALCSIZE message, I then just do this:

auto const parameters = reinterpret_cast<NCCALCSIZE_PARAMS*>(p_data_b);

if (IsMaximized(m_windowHandle)) {
	auto info = MONITORINFO{};
	info.cbSize = sizeof(MONITORINFO);
	GetMonitorInfo(MonitorFromRect(parameters->rgrc, MONITOR_DEFAULTTONEAREST), &info);

	parameters->rgrc[0] = info.rcWork;
}

return 0;

to properly fit the client area.

Hope this could help anyone.

question/request

Hello! Can you consider implementing some of these hacks in mpv?

If the aero snapping was working for borderless window in mpv, that would be very cool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.