• Stars
    star
    129
  • Rank 279,262 (Top 6 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WinCenterTitle is a simple tool that allows you to center align the text in Windows 10 titlebars, the same way it was in Windows 8, 8.1, or even 3.1.

WinCenterTitle

WinCenterTitle is a simple tool that allows you to center align the text in Windows 10 titlebars, the same way it was in Windows 8, 8.1, or even 3.1.

Installation

  • Download archive from releases
  • Unpack to folder of your choice (preconfigured for C:\WinCenterTitle)
  • Edit WinCenterTitle.xml and edit line 40, which contains path to application, according to your system
  • Register scheduled task which will enable the tweak at startup: run install.bat as administrator. This is one way of running the application using the SYSTEM account, which is required in order to be able to hook into DWM.
  • VERY IMPORTANT: Hooking DWM requires special permissions for the folder that contains the application and the library. Make sure folder owner is set to Administrators and that the Users group is added as well, with default permissions (Read & execute, List folder contents, and Read). Otherwise, the application will terminate with error code -6, being unable to hook the library into Desktop Window Manager. Also, in that folder, make sure you have a folder called "symbols", with Full Control permissions for Users group.
  • Reboot system or manually run the created scheduled task. This will center title bars for all windows. You can close or rerun the application from Task Scheduler, allowing you to toggle between center aligned and left aligned (default) title bars. No DWM restart is required and the library should leave DWM in a clean state when unloading.

To do

  • Hook window activation and optionally hide icon in title bar (could be achieved with SetWindowThemeAttribute)
  • Add option to center between window margins, as opposed to space between icon and window controls
  • User settings, system tray icon, configuration GUI etc (unlikely)

How it works

The application injects into DWM and hooks DrawText method that is used to compute the area, and draw the title bar text for the window. By doing so, we achieve the effect with least amount of overhead, as the method is called by DWM only when the window is an unskinned (no custom client side decoration aka no DwmExtendFrameIntoClientArea). After injecting, the application monitors DWM and reinjects should it crash or reload by user action.

This means that all regular windows will have their title bar text centered. Custom skinned windows require more attention; in particular, heavy skinned ones are impossible to modify unless hacks specific to the application are employed - think Visual Studio, Visual Studio Code (fortunately, it is already centered), Office (already centered as well). However, a special class of windows are left left-aligned by this tool, but we can do more regarding them: ribbon windows - think File Explorer, Paint, WordPad etc. These respect a property (CONTENTALIGNMENT) specified in the theme style file (the default is aero.msstyles). To patch this, a rather complicated process is required:

  1. Enable custom themes on your system by patching uxtheme. For this, I used UltraUXThemePatcher, but the tool does not matter.
  2. Stop WinCenterTitle if running, and then kill dwm in order to get a fresh new process.
  3. Make a copy of aero folder and aero.theme from C:\Windows\Resources\Themes in the same folder. I called mine test.theme and folder test.
  4. Rename aero.msstyles to test.msstyles from aero folder, and aero.msstyles.mui to test.msstyles.mui from aero\en-US folder. These two steps may require you to take ownership of the files.
  5. Download msstyleEditor and open the test.msstyles file in it. In the left, browse for Window\CAPTION. On the right, click + near Common and choose CONTENTAALIGNMENT from the list. Set it to Right (there is currently a bug in msstyleEditor and Centered is labeled Right and vice versa; so, when you see Right, it means Center). Repeat this for Window\MAXCAPTION on the left (credits: https://www.sevenforums.com/customization/186924-center-titlebar-text.html). Make sure to save the newly edited file at C:\Windows\Resources\Themes\test\test.msstyle.
  6. Edit C:\Windows\Resources\Themes\test.theme, and make sure Path in VisualStyles section reads %ResourceDir%\Themes\test\test.msstyles. Also, change DisplayName in Theme section to whatever you like, I changed mine to @%SystemRoot%\System32\themeui.dll,-2014 which will name the theme Windows Basic.
  7. Apply the new theme from Personalization\Themes in Settings. Notice how the title bar text is centered in Explorer. There is one issue though: the title bars are now colored, instead of default white/black. This is because DWM contains a check for the name of the msstyles file. If it is called aero.msstyles, title bars will be painted white/black, depending on whether you are on light/dark theme in Settings. If the msstyles file has any other name (like in our case), the title bar will have whatever color the msstyles file specifies, or in the case of this renamed aero.msstyles, it will use your accent color no matter if you have 'Show accent color on the following surfaces: Title bars and window borders' in Personalization\Colors in Settings checked or not. To override this behavour, WinCenterTitle has a small code block that identifies the in memory flag of DWM that holds the status of whether the theme is called aero.msstyles and overrides its value to 1, meaning that the theme is called aero.msstyles, despite its actual name, and forcing DWM to render the title bars using the default behavior. So, to complete this guide, start WinCenterTitle now and observe how the title bars will have centered text for all windows, including ribbon applications (File Explorer, WordPad, Paint etc). After aprox. 10 seconds, the title bars will also revert to their default white/black apparance, if you had them this way previously.

License

Hooking is done using the excellent funchook library (GPL with linking exception), which in turn is powered by the diStorm3 (3-clause BSD) disassembler. Thus, I am offering this under the GNU General Public License Version 2.0, which I believe is compatible.

Compiling

The following prerequisites are necessary in order to compile this project:

  • Microsoft C/C++ Optimizing Compiler - this can be obtained by installing either of these packages:

    • Visual Studio - this is a fully featured IDE; you'll need to check "C/C++ application development role" when installing. If you do not require the full suite, use the package bellow.
    • Build Tools for Visual Studio - this just installs the compiler, which you'll be able to use from the command line, or from other applications like CMake

    Download either of those here. The guide assumes you have installed either Visual Studio 2019, either Build Tools for Visual Studio 2019.

  • CMake - for easier usage, make sure to have it added to PATH during installation

  • Git - you can use Git for Windows, or git command via the Windows Subsystem for Linux.

Steps:

  1. Clone git repo along with all submodules

    git clone --recursive https://github.com/valinet/WinCenterTitle
    

    If "git" is not found as a command, type its full path, or have its folder added to PATH, or open Git command window in the respective folder if using Git for Windows.

  2. Compile funchook

    cd libs
    cd funchook
    md build
    cd build
    cmake -G "Visual Studio 16 2019" -A x64 ..
    cmake --build . --config Release
    

    If "cmake" is not found as a command, type its full path, or have its folder added to PATH.

    Type "Win32" instead of "x64" above, if compiling for x86. The command above works for x64.

  3. Compile WinCenterTitle

    • Double click the WinCenterTitle.sln to open the solution in Visual Studio. Choose Release and your processor architecture in the toolbar. Press F6 to compile.

    • Open an "x86 Native Tools Command Prompt for VS 2019" (for x86), or "x64 Native Tools Command Prompt for VS 2019" (for x64) (search that in Start), go to folder containing solution file and type:

      • For x86:

        msbuild WinCenterTitle.sln /property:Configuration=Release /property:Platform=x86
        
      • For x64:

        msbuild WinCenterTitle.sln /property:Configuration=Release /property:Platform=x64
        

    The resulting exe and dll will be in "Release" folder (if you chose x86), or "x64\Release" (if you chose x64) in the folder containing the solution file.

That's it. later, if you want to recompile, make sure to update the repository and the submodules first:

git pull
git submodule update --init --recursive

More Repositories

1

ExplorerPatcher

This project aims to enhance the working environment on Windows
C
23,156
star
2

Win11DisableRoundedCorners

A simple utility that cold patches dwm (uDWM.dll) in order to disable window rounded corners in Windows 11
C
667
star
3

ssde

SSDE is a collection of utilities that help in having Windows load your custom signed kernel drivers when Secure Boot is on and you own the system's platform key, instead of using test mode.
C++
125
star
4

ThinkPadLEDControl

ThinkPad LED Control allows controlling the various LEDs present on ThinkPad laptops and linking them to various system events (disk activity, key presses etc.) on Microsoft Windows.
C#
76
star
5

sws

sws (Simple Window Switcher) is an Alt-Tab replacement for Windows
C
63
star
6

ExplorerPatcher-L10N

Localizations for ExplorerPatcher
JavaScript
59
star
7

ep_dwm

Implements a Windows service that removes the rounded corners for windows in Windows 11
C
48
star
8

WinOverview

WinOverview is a reproduction of the GNOME Activities (Overview) for Microsoft Windows.
C++
30
star
9

libvalinet

A header-only collection of generic implementations shared between multiple projects
C
21
star
10

WinOverview2

WinOverview2 reimplements the classic Task View from earlier builds of Windows 10 that showed the windows around the center of the screen, without a timeline, and most importantly, lag free.
C
20
star
11

IMAPNotes

This is a simple Thunderbird extension (compatible with Thunderbird 78+ as of January 2021) that allows editing notes created, edited and synced from the iPhone Notes app.
JavaScript
17
star
12

network-load-balancer

Trivial Network Load Balancer is a simple user-space daemon for balancing traffic across multiple routes which lead to the Internet.
C++
16
star
13

MonitorBrightnessControl

Monitor Brightness Control is a simple daemon for Microsoft Windows that allows changing brightness for all external monitors at once using a system tray icon.
C
15
star
14

ThunderbirdToasts

Thunderbird Toasts is a simple framework that allows Thunderbird to send Windows 10 toasts as notifications instead of its custom popup notifications that are not native.
C
15
star
15

HideExplorerSearchBar

Very simple executable that hides the search bar in File Explorer and in the Open/Save dialogs in Windows 10.
C
10
star
16

kb_light

ThinkPad Keyboard Backlight Manager is a simple Windows service that maintains keyboard backlight across reboots and temporarily shuts it off when a full screen application is in use.
C
10
star
17

ArchiveMenu

Associate your archive formats with Archive Menu, and when double clicking an archive, a popup menu will show, allowing you to open or extract the contents, using 7zip.
C
9
star
18

rt

Restarter (Restart Task) is a simple Win32 application (Windows subsystem) that continously launches an application specified in its arguments, waits for its termination, and repeats the cycle.
C
7
star
19

ep_make

Portable build environment for ExplorerPatcher
PowerShell
6
star
20

ShutdownDaemon

Implements a mechanism to find whether the system is shutting down or rebooting in Windows.
C++
5
star
21

valinet

This repository contains the text that is displayed in the Overview section of my GitHub profile
3
star
22

QtCreatorBlackTitlebar

Makes the title bar of Qt Creator black in Windows
C
3
star
23

audiopot-plus

AudioPot+ is the second attempt at producing a volume knob for a computer using an Arduino.
C++
3
star
24

VbsPolicyDisableEFI

EFI driver which disables Virtualization-based Security (VBS) in Microsoft Windows
3
star
25

homepi-plus

homepi+ is an Arduino based implementation of a home control system.
C++
2
star
26

AudioPot

Provides Arduino code for reporting potentiometer values and a service for interpreting and acting on the received data.
C
2
star
27

MDNSAdvertiser

Simple Win32 application that advertises a domain name for a host in the local LAN using mDNS.
C
1
star
28

homepi

homepi is a set of configuration data and front end files for the Raspberry Pi that automates my home office setup.
C
1
star
29

MonitorDaemon

A simple executable that turns on/off the monitor on certain system events.
C++
1
star
30

valinet.github.io

Source code for valinet.ro
SCSS
1
star
31

SharePointLinkHelper

SharePoint Link Helper registers a protocol that can be used to open files from SharePoint in the correct local application or view the current folder in File Explorer even in modern browsers.
C
1
star
32

TMLauncher

An old project that provides a service to launch a modified Task Manager (I hardcoded IsServer=0) executable without requiring elevation.
C
1
star
33

EtherCard-MDNS

Simple multicast DNS name resolution and service discovery library for EtherCard library that works with the ENC28J60 module.
C++
1
star
34

homepi-android-client

An Android client for homepi that displays the web UI automatically by using the built-in mDNS API of the OS that is not yet exposed to the default resolver, hence most browsers on Android still cannot resolve .local addresses.
Java
1
star
35

xps15kbfix

A simple Windows PS/2 filter driver based on the sample from Microsoft that remaps some keys on the Dell XPS 15 7590's keyboard to my personal preference.
C
1
star
36

VbsPolicyDisabledEFI

EFI driver which disables Virtualization-based Security (VBS) in Microsoft Windows
1
star