lights FAQ Forum

Native OS APIs


Win32 windows & controls


Windows, common controls and dialogs, message loop and system APIs.


  • UTF8 Lua strings everywhere (also works with wide char buffers)
  • bitmap widget for custom painting
  • OpenGL and cairo custom-painting widgets (in separate packages)
  • anchor-based layout model for all controls
  • object system with virtual properties (win.title = 'hello' sets the title)
  • binding helpers for easy binding of new and future APIs
  • all calls are error-checked
  • automatic memory management (ownership; buffers)
  • flags can be passed as 'FLAG1 FLAG2'
  • counting from 1 everywhere.


Current status and issues.

Hello World

local winapi = require'winapi'

local win = winapi.Window{
   w = 500,                --all these are "initial fields"
   h = 300,
   title = 'Lua rulez',
   autoquit = true,        --this is to quit app when the window is closed
   visible = false,        --this field is from BaseWindow

function win:on_close()    --this is an event handler

print(win.title)           --this is how to read the value of a property
win.title = 'Lua rulez!'   --this is how to set the value of a property
win:show()                 --this is a method call

os.exit(winapi.MessageLoop()) --start the message loop


Check out winapi_demo to see all the controls in action:



Also, many modules can be run as standalone scripts, which will showcase their functionality, so there's lots of little demos there too.




  • Object - objects
    • VObject - objects with virtual properties
      • BaseWindow - base class for top-level windows and controls
      • [Menu][winapi.menuclass] - menus and menu bars
      • [NotifyIcon][winapi.notifyiconclass] - system tray icons


The "proc" layer is documented in the code, including API quirks and empirical knowledge, so do check out the source code.


bindinglast updated
winapi.bitmask Bitmask encoding and decoding 3 years ago
winapi.debug Strict mode and debug tools (optional module) 3 years ago
winapi.namespace Namespace module and utils 3 years ago
winapi.struct Struct ctype wrapper 5 months ago
winapi.util Binding utilities 4 months ago
winapi.wcs Utf8 <-> wide char conversions 3 years ago
winapi [doc] Win32 windows & controls 3 years ago
winapi.init Main winapi module 3 years ago
oo/abstractlast updated
winapi.basewindowclass [doc] Base class for windows and controls 2 months ago
winapi.controlclass [doc] Base class for controls 11 months ago
winapi.handlelist Handle to Lua object mapping 3 years ago
winapi.itemlist Base class for lists of objects 3 years ago
oo/controlslast updated
winapi.basebuttonclass [doc] Base class for button-like controls 3 years ago
winapi.bitmappanel [doc] RGBA bitmap panels 3 years ago
winapi.buttonclass [doc] Push-buttons 3 years ago
winapi.checkboxclass [doc] Checkboxes 3 years ago
winapi.comboboxclass [doc] Combo boxes and drop-down lists 3 years ago
winapi.editclass [doc] Edit boxes 3 years ago
winapi.groupboxclass [doc] Group boxes 3 years ago
winapi.labelclass [doc] Text labels 3 years ago
winapi.listboxclass [doc] List boxes 3 years ago
winapi.listviewclass Standard listview control 5 months ago
winapi.menuclass Standard menu control 3 years ago
winapi.notifyiconclass System tray icons 2 years ago
winapi.panelclass [doc] Custom-painted child windows 3 years ago
winapi.radiobuttonclass [doc] Radio buttons 3 years ago
winapi.tabcontrolclass Standard tab control 3 years ago
winapi.toolbarclass Standard toolbar control 3 years ago
winapi.tooltipclass Standard tooltip control 5 months ago
winapi.waitemlistclass Accelerator item list 3 years ago
oo/oo-systemlast updated
winapi.class [doc] Single inheritance object model 3 years ago
winapi.object [doc] The root class 3 years ago
winapi.vobject [doc] Objects with virtual properties 3 years ago
oo/resourceslast updated
winapi.imagelistclass Image lists 3 years ago
oo/systemlast updated
winapi.mmdeviceclass Windows Multimedia Device API 3 years ago
oo/windowslast updated
winapi.windowclass [doc] Top-level windows 4 months ago
proc/controlslast updated
winapi.accelerator Accelerator tables 3 years ago
winapi.button Button and button-like controls 3 years ago
winapi.combobox Old combobox control 3 years ago
winapi.comboboxex Comctl32 combobox control 3 years ago
winapi.comctl Common controls API 3 years ago
winapi.edit Standard edit control 3 years ago
winapi.filedialogs Standard open and save dialogs 3 years ago
winapi.headercontrol Standard header control 3 years ago
winapi.listbox Standard listbox control 3 years ago
winapi.listview Standard listview control 3 years ago Standard menu control 3 years ago
winapi.messagebox Standard message box dialog 3 years ago
winapi.richedit Standard richedit control 3 years ago
winapi.static Label/shape/image control 3 years ago
winapi.tabcontrol Standard tab control 3 years ago
winapi.toolbar Standard toolbar control 5 months ago
winapi.tooltip Standard tooltip control 5 months ago
winapi.treeview Standard treeview control 3 years ago
proc/dialogslast updated
winapi.colorchooser Color chooser dialog 3 years ago
winapi.comdlg Common dialogs API 3 years ago
proc/gdilast updated
winapi.bitmap Bitmap API 3 years ago
winapi.ddev Display Devices API 3 years ago
winapi.devcaps Device capabilities API 3 years ago
winapi.dibitmap RGBA device independent bitmaps 3 years ago
proc/inputlast updated
winapi.keyboard Keyboard API 5 months ago
winapi.mouse Mouse API 3 years ago
winapi.rawinput Raw Input API 3 years ago
proc/multimedialast updated
winapi.dsound DirectSound API 3 years ago
proc/olelast updated
winapi.idataobject IDataObject interface 3 years ago
winapi.dragdrop Drag & drop OLE API 4 years ago
winapi.ienumformatetc IEnumFormatETC interface 3 years ago
proc/resourceslast updated
winapi.color Standard color brushes 3 years ago
winapi.cursor Cursor resources 7 months ago
winapi.font Font resources (the old API) 3 years ago
winapi.fontex Font resources (the new API) 3 years ago
winapi.icon Icon resources 3 years ago
winapi.imagelist Image lists 3 years ago
winapi.resource LoadImage API 3 years ago
proc/systemlast updated
winapi.clipboard Clipboard API 3 years ago
winapi.filemapping Memory mapped files 3 years ago
winapi.memory Memory Management API 3 years ago
winapi.mmdevice Windows Multimedia Device API 3 years ago
winapi.mmsystem Multimedia API 3 years ago
winapi.module LoadLibrary API 5 months ago
winapi.monitor Monitor API 3 years ago
winapi.ole OLE API 3 years ago
winapi.process Process API 3 years ago
winapi.propsys Property System API 3 years ago
winapi.registry Registry API 3 years ago
winapi.rpc RPC types 3 years ago
winapi.shellapi Shell32 API 3 years ago
winapi.spi System Parameters Info API 3 years ago
winapi.sstorage Structured Storage API 3 years ago
winapi.sync Synchronization API 5 months ago
winapi.sysinfo System Info API 3 years ago
winapi.systemmetrics System Metrics API 3 years ago
winapi.time Time functions 3 years ago
winapi.uuid UUID API from rpcdce.h 3 years ago
winapi.winbase Winbase.h. incomplete :) 3 years ago
winapi.winnt Don't know the scope of this yet 3 years ago
proclast updated
winapi.volman Volume Management API 5 months ago
proc/windowslast updated
winapi.windowclasses WNDCLASSEX API 3 years ago
winapi.dpiaware DPI-awareness API 3 years ago
winapi.gdi GDI API 3 years ago
winapi.window Windows (as in HWND) API 5 months ago
winapi.wmapp User-defined (WM_APP+N) messages 5 months ago
testlast updated
winapi.showcase Testing utilities 3 years ago
typeslast updated
winapi.logfonttype LOGFONTW type 3 years ago
winapi.types Types and macros from multiple headers 3 years ago
winapi.winuser Winuser types and macros from multiple headers 3 years ago

Last updated: 5 months ago | Edit on GitHub

Pkg type:Lua+ffi
Version: r5-0-gb9d53e5
Last commit:
License: Public Domain
Requires: glue  luajit 
Required by: cairo  cplayer  nw  winapi.cairopanel  winapi.wglpanel  ui