lights FAQ Forum

Native OS APIs


win32 windows & controls


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


  • UTF8 Lua strings everywhere (also works with wide char buffers)
  • OpenGL, cairo and bitmap widgets
  • 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 20 months ago
winapi.debug strict mode and debug tools (optional module) 19 months ago
winapi.namespace namespace module and utils 20 months ago
winapi.struct struct ctype wrapper 19 months ago
winapi.util binding utilities 19 months ago
winapi.wcs utf8 <-> wide char conversions 19 months ago
winapi.init main winapi module 19 months ago
winapi [doc] loader for winapi.init (or the demo if run standalone) 19 months ago
oo/abstractlast updated
winapi.basewindowclass [doc] base class for top-level windows and controls 19 months ago
winapi.controlclass [doc] base class for standard controls 19 months ago
winapi.handlelist handle to Lua object mapping 20 months ago
winapi.itemlist base class for lists of objects 20 months ago
oo/controlslast updated
winapi.basebuttonclass [doc] base class for button-like controls 19 months ago
winapi.bitmappanel [doc] RGBA bitmap control 19 months ago
winapi.buttonclass [doc] push-button control 20 months ago
winapi.cairopanel [doc] cairo pixman surface control 15 months ago
winapi.cairosgpanel cairo scene graph panel 20 months ago
winapi.checkboxclass [doc] checkbox control 20 months ago
winapi.comboboxclass [doc] ComboBoxEx32 control 19 months ago
winapi.editclass [doc] standard edit control 19 months ago
winapi.groupboxclass [doc] groupbox control 20 months ago
winapi.labelclass [doc] standard label control 19 months ago
winapi.listboxclass [doc] standard listbox control 19 months ago
winapi.listviewclass standard listview control 19 months ago
winapi.menuclass standard menu control 19 months ago
winapi.notifyiconclass system tray icons 15 months ago
winapi.panelclass [doc] custom frameless child windows 19 months ago
winapi.radiobuttonclass [doc] radio button control 20 months ago
winapi.tabcontrolclass standard tab control 19 months ago
winapi.toolbarclass standard toolbar control 19 months ago
winapi.waitemlistclass accelerator item list 19 months ago
winapi.wglpanel [doc] opengl-enabled panel 19 months ago
oo/oo-systemlast updated
winapi.class [doc] single inheritance object model 20 months ago
winapi.object [doc] base object class 20 months ago
winapi.vobject [doc] object class with virtual properties 20 months ago
oo/resourceslast updated
winapi.imagelistclass image lists 20 months ago
oo/systemlast updated
winapi.mmdeviceclass Windows Multimedia Device API 20 months ago
oo/windowslast updated
winapi.windowclass [doc] overlapping (aka top-level) windows 19 months ago
proc/controlslast updated
winapi.accelerator accelerator tables 20 months ago
winapi.button button and button-like controls 19 months ago
winapi.combobox old combobox control 20 months ago
winapi.comboboxex comctl32 combobox control 20 months ago
winapi.comctl common controls API 19 months ago
winapi.edit standard edit control 20 months ago
winapi.filedialogs standard open and save dialogs 20 months ago
winapi.headercontrol standard header control 20 months ago
winapi.listbox standard listbox control 19 months ago
winapi.listview standard listview control 20 months ago standard menu control 20 months ago
winapi.messagebox standard message box dialog 20 months ago
winapi.richedit standard richedit control 20 months ago
winapi.static label/shape/image control 19 months ago
winapi.tabcontrol standard tab control 19 months ago
winapi.toolbar standard toolbar control 19 months ago
winapi.tooltip standard tooltip control 20 months ago
winapi.treeview standard treeview control 20 months ago
proc/dialogslast updated
winapi.colorchooser color chooser dialog 20 months ago
winapi.comdlg common dialogs API 20 months ago
proc/gdilast updated
winapi.bitmap bitmap API 20 months ago
winapi.ddev Display Devices API 19 months ago
winapi.devcaps device capabilities API 20 months ago
winapi.dibitmap RGBA device independent bitmaps 19 months ago
proc/inputlast updated
winapi.keyboard Keyboard API 20 months ago
winapi.mouse Mouse API 20 months ago
winapi.rawinput Raw Input API 19 months ago
proc/multimedialast updated
winapi.dsound DirectSound API 18 months ago
proc/olelast updated
winapi.idataobject IDataObject interface 20 months ago
winapi.dragdrop drag & drop OLE API 2 years ago
winapi.ienumformatetc IEnumFormatETC interface 20 months ago
proc/opengllast updated opengl dynamic namespace 20 months ago
winapi.gl11 OpenGL 1.1 API 20 months ago
winapi.gl21 OpenGL 2.1 API 20 months ago
winapi.wgl WGL API from wingdi.h 20 months ago
winapi.wglext opengl WGL API from wglext.h 20 months ago
proc/resourceslast updated
winapi.color standard color brushes 20 months ago
winapi.cursor cursor resources 19 months ago
winapi.font font resources (the old API) 19 months ago
winapi.fontex font resources (the new API) 20 months ago
winapi.icon icon resources 20 months ago
winapi.imagelist image lists 19 months ago
winapi.resource LoadImage API 20 months ago
proc/systemlast updated
winapi.clipboard clipboard API 20 months ago
winapi.file file I/O 20 months ago
winapi.filemapping memory mapped files 20 months ago
winapi.memory Memory Management API 20 months ago
winapi.mmdevice Windows Multimedia Device API 20 months ago
winapi.mmsystem Multimedia API 18 months ago
winapi.module LoadLibrary API 20 months ago
winapi.monitor Monitor API 19 months ago
winapi.ole OLE API 18 months ago
winapi.process Process API 20 months ago
winapi.propsys Property System API 20 months ago
winapi.registry Registry API 20 months ago
winapi.rpc RPC types 20 months ago
winapi.shellapi Shell32 API 20 months ago
winapi.spi System Parameters Info API 20 months ago
winapi.sstorage Structured Storage API 20 months ago
winapi.sysinfo System Info API 20 months ago
winapi.systemmetrics System Metrics API 20 months ago
winapi.time time functions 20 months ago
winapi.uuid UUID API from rpcdce.h 20 months ago
winapi.winbase winbase.h. incomplete :) 20 months ago
winapi.winnt don't know the scope of this yet. 20 months ago
proc/windowslast updated
winapi.windowclasses WNDCLASSEX API 19 months ago
winapi.dpiaware DPI-awareness API 20 months ago
winapi.gdi GDI API 19 months ago
winapi.window Windows (as in HWND) API 19 months ago
winapi.wmapp user-defined (WM_APP+N) messages 20 months ago
testlast updated
winapi.showcase testing utilities 20 months ago
typeslast updated
winapi.logfonttype LOGFONTW type 20 months ago
winapi.types types and macros from multiple headers 18 months ago
winapi.winuser winuser types and macros from multiple headers 19 months ago

Last updated: 19 months ago | Edit on GitHub

Pkg type:Lua+ffi
Version: r3-6-g9e08232
Last commit:
License: PD
Requires: cairo  glue  luajit  opengl  sg  +eq  +ffi_reflect  +path2d  +pp 
Required by: cairo  cplayer  nw  opengl  sg