Skip to content

happymimimix/libTridentUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 

Repository files navigation

libTridentUI

Want to develop a browser-based desktop application for legacy operating systems? Try libTridentUI!

-- An extremely lightweight Chrome Embedded Framework alternative for legacy operating systems.

-- Works perfectly on Microsoft Windows XP SP3!

Why use libTridentUI?

  1. Extremely lightweight

    Modern browser based UI frameworks like Electron, CEF, and WebView2 are powerful but extremely heavy.

    They ship a full Chromium browser with your app which would obviously occupy a huge amount of storage space and require modern OS versions.

    If you're building a lightweight desktop utility that needs a rich UI but also needs to run on legacy systems, your options are very limited.

    This is where libTridentUI can help you!

    Every copy of Windows since Windows 95 ships with mshtml.dll (the Trident/IE engine) that is capable of rendering HTML.

    Not only it's extremely tiny, but it also ships together with Windows so you don't even have to install it additionally! It's already sitting there inside EVERY single Windows machine around the world just waiting to be called.

    And that's exactly what libTridentUI is doing: An extremely lightweight single header library that calls mshtml.dll to render the UI of your software with zero DLL dependencies beyond what Windows already provides!

  2. Maximum compatibility assurance

    libTridentUI is built on Microsoft Internet Explorer’s Trident engine, capable of offering absolute top-tier compatibility!!!

    • Windows 2000 SP4 (⚠ Untested but expected to work)
    • Windows XP SP3
    • Windows Vista SP1
    • Windows 7 SP1
    • Windows 8
    • Windows 8.1
    • Windows 10 2004
    • Windows 11 21H2
    • Linux 5+ with WineHQ (Will be supported in near future)
    • MacOS 10+ with CrossOver (Will be supported in near future)
    • Android 11+ with Winlator (Will be supported in near future)

    You can now create browser based programs that works across all versions of Windows spanning a period of 20 years! Isn't that beautiful?

  3. Easy to use

    libTridentUI wrapped all of the complex COM interfaces needed to host mshtml.dll into a clean and flat C-Style API that you can quickly learn in just a few hours!

    No need to create any class or struct, no need to implement any COM interface yourself, libTridentUI has already done all of the heavy lifting for you.

  4. Multifunctional

    Other libraries might only provide you a web browser window that can only run the slow as hell JavaScript and nothing else, but libTridentUI provides you a fully working IDispatch implementation that allows you to call C++ functions from JS and call JS functions from C++ with zero effort!

    In addition, libTridentUI also supports embedding custom ActiveX controls into your webpage! Instead of the 0.1 fps JS Canvas, you now have access to a GDI compatible hWnd that you can render complex graphics with lightning speed using C++ via GDI Plus, DirectX, or OpenGL.

    The ActiveX component registration is done completely in RAM, no registry writes, no uninstallation leftover!

  5. Top-tier library code complexity and user code complexity balance

    libTridentUI only implements what's worth doing with absolute minimal bloat!

    We do NOT reinvent COM like some other libraries do.

    image

Supported features

Window hosting

  • Create standalone Trident windows (WS_OVERLAPPEDWINDOW)
  • Create child Trident windows (WS_CHILD, embed inside other windows)
  • Create popup Trident windows (WS_POPUP)
  • Custom extended window styles (WS_EX_*)
  • Custom WndProc for host window messages
  • Per-window user data storage
  • Multiple simultaneous windows
  • Proper window lifecycle (WM_NCDESTROY cleanup)

Navigation

  • Navigate to URL (http://, https://, file://)
  • Navigate to embedded resource (res:// protocol)
  • Navigate to HTML string (document.write injection)
  • Access IWebBrowser2 directly for advanced control

JavaScript ↔ C++ bridge

  • Call C++ functions from JS (window.external.MyFunc)
  • Call JS functions from C++ (ExecScript)
  • Pass arguments: int, double, string, bool
  • Return values from C++ to JS
  • Return values from JS to C++
  • Async callbacks from C++ to JS
  • Create & parse JS arrays (comming soon)
  • Create & parse JS objects (comming soon)
  • Create & parse JS anonymous functions (comming soon)

DOM manipulation from C++

  • Get element by ID
  • Get/set innerHTML
  • Get/set innerText
  • Set outerHTML
  • Get/set attributes
  • Set CSS class
  • Set inline style
  • Convenience functions (SetElementHTML, SetElementText by ID)
  • Create/remove elements from C++
  • Query elements by class/tag/CSS selector
  • Event listener management from C++

ActiveX control creation

  • Register custom control classes (in-memory, no registry writes)
  • Deterministic CLSID generation from name (MD5 hash)
  • Embed controls in HTML via <object> tag
  • Custom WndProc for control messages (WM_PAINT, WM_CREATE, etc.)
  • Per-control-class and per-instance user data
  • Automatic HIMETRIC ↔ pixel size conversion

ActiveX IDispatch (JS ↔ control methods)

  • Bind methods callable from JS (canvas1.Add(3,7))
  • Bind readable/writable properties (canvas1.Counter)
  • Getter-only and setter-only properties
  • IDispatch argument passing (int, string, double, bool, IDispatch)
  • Optional/default parameter values
  • Automatic cyclecount conversion between JS and C++ types

ActiveX event system

  • Register named events with parameter count
  • Fire events from C++ to JS with typed arguments
  • Fire events by DISPID or by name
  • Native IE attachEvent() support via ITypeInfo/IProvideClassInfo2
  • Coclass + dispatch dual-layer type information
  • Query expected argument count per event
  • Re-entrant safe event firing (sink snapshot with AddRef)
  • detachEvent() from C++ side
  • Custom event object (IE uses plain DISPPARAMS, not DOM Event)

OLE Drag & Drop

  • Drop target: accept dragged data onto controls
  • Drop source: initiate drag from controls
  • DragEnter / DragOver / DragLeave / Drop callbacks
  • Text data transfer (CF_UNICODETEXT)
  • File drop from Explorer (CF_HDROP)
  • CreateTextDataObject helper
  • StartDragDrop helper
  • Custom clipboard formats
  • Drag image / visual feedback customization
  • IDropTargetHelper integration

IDocHostUIHandler customization

  • Context menu control (block or allow default IE menu)
  • Host UI flags (3D border, DPI awareness, themes)
  • External object (window.external) injection
  • Keyboard accelerator forwarding
  • Custom context menu implementation from C++
  • Custom error page handling (IDocHostShowUI)
  • Download manager integration (IDownloadManager)
  • Custom security manager (IInternetSecurityManager)

Architecture

  • Single header library (header-only, no .lib/.dll needed)
  • C-style flat API (no classes/inheritance needed by user)
  • Thread safety annotations (STA thread requirement documented)
  • Re-entrancy protection (critical sections on IDispatch maps)
  • Reference-counted COM objects with InterlockedIncrement/Decrement
  • Doubly-linked window list for O(1) removal
  • Separate message loop modes (full loop vs. per-message processing)
  • Thread-safe API (all calls must be from STA thread)
  • Multiple STA thread support (one Trident instance per thread)

About

An extremely lightweight Chrome Embedded Framework alternative for legacy operating systems.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages