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.




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

Last updated: 3 years ago | Edit on GitHub

Pkg type:Lua+ffi
Version: 84c32de
Last commit:
License: Public Domain

Requires: +events  +glue  +luajit 

Required by: cairo  cplayer  hidapi  nw  proc  sock  winapi.cairopanel  winapi.wglpanel  dollar  opengl  testui  ui