caption-switcher
Windows caption manipulation. Legacy Object Pascal application for learning Windows API programming. Delphi 7 educational project discontinued 2013.
- Active · last change 11-4-2026
- ★ 4 on GitHub
README
Caption Switcher
A lightweight Windows utility built entirely in Object Pascal using raw Win32 API calls (no VCL) that enumerates all visible top-level windows and allows the user to change their title bar text (caption) in real-time. The entire application is a single .dpr file with zero runtime library dependencies. This project was developed for educational purposes and is no longer actively maintained (discontinued 2013-03-28).
Features
- Window Enumeration -- uses
EnumWindowswith a custom callback to discover all visible, top-level windows (excluding toolwindows and child windows), populating a sorted listbox - Caption Modification -- changes any window's title bar text using
FindWindowAandSetWindowTextA, applying the new caption immediately - Zero-VCL Architecture -- the entire UI is built with raw Win32 API calls:
CreateWindowExAfor all controls (ListBox, Edit, Button, Static, GroupBox),RegisterClassAfor the window class, and a manualGetMessageA/TranslateMessage/DispatchMessageAmessage loop - Custom Dark Theme -- implements a dark color scheme through
WM_CTLCOLORLISTBOX,WM_CTLCOLORSTATIC, andWM_CTLCOLOREDITmessage handlers, setting white text on dark backgrounds with customHBRUSHpainting - Window Transparency -- applies
WS_EX_LAYEREDwithSetLayeredWindowAttributesfor configurable alpha transparency on the main form - XP Visual Styles -- includes a Windows XP application manifest (
XPManifest.Manifest) embedded as a Win32 resource, enabling themed common controls viacomctl32.dllversion 6 - Custom Icons -- ships with multiple icon sizes (32x32, 64x64) embedded as resources, applied to the form via
WM_SETICONandSetClassLong - Custom Font Rendering -- creates a "Times New Roman" font via
CreateFontAand applies it to all controls withWM_SETFONT - Centered Window Placement -- calculates screen center position using
GetSystemMetrics(SM_CXSCREEN)andSM_CYSCREEN - Refresh Capability -- "Atualizar" button clears and re-enumerates all windows on demand
- Click-to-Select -- clicking a window name in the listbox automatically fills the "current caption" field via
LB_GETCURSELandLB_GETTEXT
Technologies
| Component | Details |
|---|---|
| Language | Object Pascal (Delphi 7) -- pure Win32 API, zero VCL |
| APIs | Windows.pas, Messages.pas (kernel32, user32, gdi32, comctl32) |
| UI | Raw CreateWindowExA controls: ListBox, Edit, Button, Static, GroupBox |
| Theming | XP Manifest (Common Controls 6.0) + custom WM_CTLCOLOR* dark theme |
Project Structure
caption-switcher/
????????? CS.dpr # Complete application source - window class, UI creation, message loop, window enumeration
????????? XPManifest/
??? ????????? XPManifest.Manifest # Windows XP application manifest (Common Controls 6.0.0.0)
??? ????????? XPManifest.rc # Resource compiler script for the manifest
????????? ConIcon/
??? ????????? ConIcon.rc # Resource compiler script for icons (CONICON, ICO32, ICO64)
??? ????????? Icon.ico # Default application icon
??? ????????? Icon.png # Icon source image
??? ????????? 32x32.ico # Small icon (taskbar, title bar)
??? ????????? 64x64.ico # Large icon (Alt+Tab, taskbar)
????????? LICENSE # GNU General Public License v3.0
????????? README.mdUI Layout
The application window ("Caption Switcher v1.0", 346x324 pixels) is divided into two sections:
?????? Janelas Detectadas (Detected Windows) ???????????????????????????
??? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???
??? ??? Sorted ListBox of visible windows ??? ???
??? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???
??? [ Atualizar ] ???
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????? Titulo da Janela (Window Title) ????????????????????????????????????????????????
??? Atual: [ current caption (read-only) ] ???
??? Novo: [ new caption input ] ???
??? [ Setar ] [ Limpar ] ???
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Criado Por rios0rios0 ...Workflow
- Click Atualizar to populate the list with all visible windows
- Click a window name in the list -- its current caption fills the "Atual" field
- Type the desired new caption in the "Novo" field
- Click Setar to apply the change
- Click Limpar to clear both fields
Installation
- Compile the resource files:
brcc32 XPManifest\XPManifest.rcandbrcc32 ConIcon\ConIcon.rc(no.resis committed, andCS.dprlinksXPManifest\XPManifest.resdirectly) - Open
CS.dprin Borland Delphi 7 (or a compatible IDE) - Compile the project (Ctrl+F9)
Technical Details
Window Enumeration Filter
The EnumWindowsProc callback filters windows using three criteria:
IsWindowVisible(Wnd)-- only visible windowsGetWindowLong(Wnd, GWL_HWNDPARENT) = 0or parent is the desktop -- only top-level windows(GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0-- excludes tool windows
Custom Color Painting
The application handles three color messages to achieve its dark theme:
WM_CTLCOLORLISTBOX-- sets$FFFFFFtext and black (0) background on the listboxWM_CTLCOLORSTATIC-- applies the same scheme to static labels and read-only edit controlsWM_CTLCOLOREDIT-- applies dark styling to the editable text input
Contributing
This project is no longer actively maintained. See CONTRIBUTING.md for historical build information.
License
This project is licensed under the GNU General Public License v3.0.

