Skip to content

About

Windows laptop battery monitor with system tray, customizable alerts, discharge estimation, and INI-based settings (C++ Builder 6.0)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

BatteryMonitor

C++ Builder Platform VCL License

Windows laptop battery monitor with real-time charge display, system tray integration, customizable audio and message alerts, discharge time estimation, and persistent INI configuration. Originally named "StanBaterii."

Features

  • Real-time battery gauge -- displays current charge percentage using a TCGauge progress indicator, updated by a periodic timer polling GetSystemPowerStatus()
  • Charging animation -- a secondary progress bar animates while the system is connected to AC power (charging state detected via BatteryFlag & 8)
  • System tray integration -- minimizes to the Windows notification area with a TTrayIcon component; icon switches between charging and discharging states via an ImageList
  • Customizable sound alerts -- plays a user-selected WAV file when battery drops below a configurable percentage threshold
  • Low-battery message dialog -- displays a custom warning message (default: "Bateria na wyczerpaniu") at an independently configurable threshold
  • Discharge time estimation -- estimates remaining battery life using linear approximation based on observed discharge rate over time
  • Always-on-top option -- optionally keeps the monitor window above all other windows (fsStayOnTop)
  • Draggable borderless window -- supports moving the window by clicking and dragging anywhere on the form surface
  • Persistent INI configuration -- saves and restores all settings (window position, size, alert thresholds, sound file path, startup preferences) to an INI file alongside the executable
  • Settings dialog -- a dedicated settings form (TForm2) exposes all configurable options: always-on-top, start with Windows, sound alerts, alert thresholds, sound file path, and custom warning message

Dependencies

Dependency Purpose
C++ Builder 6.0 IDE and compiler
VCL (Visual Component Library) GUI framework
CGAUGES component Circular/linear gauge widget
trayicon component System tray icon integration
Windows API (GetSystemPowerStatus) Battery status polling
IniFiles.hpp INI file read/write

Build Instructions

  1. Open StanBaterii.bpr in Borland C++ Builder 6.0.
  2. Ensure the CGAUGES and trayicon third-party components are installed in the IDE.
  3. Build the project (Ctrl+F9) or run directly (F9).

Project Structure

StanBaterii/
  StanBaterii.bpr       # C++ Builder project file
  StanBaterii.cpp       # WinMain entry point -- initializes Form1 and Form2
  StanBaterii.res       # Compiled resource file
  StanBaterii.INI       # Configuration file (window position, alert settings)
  Unit1.cpp             # Main form -- battery polling, gauge update, tray icon, alerts
  Unit1.h               # Main form header -- TForm1 class declaration
  Unit1.dfm             # Main form layout
  ustawienia.cpp        # Settings dialog -- threshold sliders, sound file picker
  ustawienia.h          # Settings dialog header -- TForm2 class declaration
  ustawienia.dfm        # Settings dialog layout

INI Configuration

The application stores all settings in StanBaterii.INI:

Key Type Description
left, top Integer Window position
height, width Integer Window dimensions
ontop Boolean Always-on-top mode
winstart Boolean Launch at Windows startup
playsound Boolean Enable low-battery sound alert
percenttoplay Integer Battery % threshold for sound alert
playfile String Path to WAV file for sound alert
showinfo Boolean Enable low-battery message dialog
percenttoshowinfo Integer Battery % threshold for message dialog
message String Custom warning message text

Screenshot

image

About

Windows laptop battery monitor with system tray, customizable alerts, discharge estimation, and INI-based settings (C++ Builder 6.0)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages