win32 windows & controls

View on GitHub
Download as .tar.gz
Download as .zip


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


  • accepting and returning UTF8 Lua strings (also accepting wide char buffers)
  • all winapi calls are error-checked so you don't have to
  • automatic memory management (ownership management, allocation of in/out buffers)
  • flags can be passed as 'FLAG1 FLAG2'
  • counting from 1 everywhere
  • object system with virtual properties (eg. window.w = 500 changes a window's width)
  • Delphi-style anchor-based layout model for all controls
  • binding infrastructure tailored to winapi conventions, facilitating the binding of more APIs
  • cairo, OpenGL and OpenVG panel widgets.


binding infrastructure
winapi.init load the namespace + ffi tools + types
winapi.namespace the namespace table
winapi.util wrapping and conversion functions
winapi.struct struct ctype wrapper
winapi.bitmask bitmask encoding and decoding
winapi.wcs utf8 to wide character string and back
winapi.debug strict mode and debug tools. entirely optional module
winapi.types windows types and macros from multiple headers
winapi.winuser winuser types and macros from multiple headers
winapi.logfonttype LOGFONTW type
winapi.window windows and standard controls
standard controls
winapi.comctl common controls
winapi.messagebox standard message box dialog
winapi.button button and button-like controls
winapi.combobox standard (old, not comctl-based) combobox control
winapi.comboboxex standard (new, from comctl32) combobox control
winapi.headercontrol standard header control
winapi.listbox standard listbox control
winapi.listview standard listview control standard menu control
winapi.accelerator accelerators
winapi.richedit standard richedit control
winapi.edit standard edit control
winapi.static standard static (aka label, text) control
winapi.tabcontrol standard tab control
winapi.toolbar standard toolbar control
winapi.tooltip standard tooltip control
winapi.treeview standard treeview control
standard dialogs
winapi.comdlg common dialogs
winapi.colorchooser color chooser dialog
winapi.filedialogs standard open and save file dialogs
winapi.resource part of winuser dealing with resources
winapi.cursor cursor resources
winapi.font font resources
winapi.fontex font resources (new API)
winapi.icon icon resources
winapi.color standard color brushes
winapi.imagelist image list resources
support APIs
winapi.mouse mouse API
winapi.keyboard keyboard input handling and keyboard layouts
winapi.rawinput raw input handling
winapi.memory memory management
winapi.process process API
winapi.registry registry API
winapi.sysinfo system info API
winapi.shellapi shell API
winapi.systemmetrics system metrics API
winapi.spi system parameters info API
winapi.winbase winbase.h. incomplete :)
winapi.winnt don't know the scope of this yet
winapi.monitor multi-monitor API
winapi.clipboard clipboard access
winapi.rpc RPC runtime and types
winapi.uuid UUID API from rpcdce.h
winapi.module winuser submodule that deals with dlls
winapi.gdi windows GDI API
opengl opengl dynamic namespace based on PFN*PROC cdefs and wglGetProcAddress
winapi.gl11 opengl 1.1 API
winapi.gl21 opengl 2.1 API
winapi.wgl windows opengl32 ffi module and WGL API from wingdi.h
winapi.wglext opengl WGL API from wglext.h
oo system
winapi.class single inheritance object model
winapi.object base object class
winapi.vobject base object class with virtual properties
oo core classes
winapi.handlelist track objects by their corresponding 32bit pointer handle
winapi.imagelistclass image list class
oo windows
winapi.basewindowclass base class for both overlapping windows and controls
winapi.windowclass overlapping (aka top-level) windows
winapi.showcase showcase window for the showcase part of modules
oo controls
winapi.controlclass base class for standard controls
winapi.panelclass custom frameless child window
winapi.basebuttonclass base class for push-buttons, checkboxes, radio buttons
winapi.buttonclass push-button control
winapi.checkboxclass checkbox control
winapi.comboboxclass standard combobox control based on ComboBoxEx32 control
winapi.editclass standard edit control
winapi.groupboxclass groupbox control
winapi.itemlist class template for lists of structured items
winapi.listboxclass standard listbox control
winapi.listviewclass standard listview control
winapi.menuclass standard menu control
winapi.radiobuttonclass radio button control
winapi.toolbarclass standard toolbar control
winapi.tabcontrolclass standard tab control
winapi.waitemlistclass accelerator item list
oo custom panels
winapi.wglpanel opengl-enabled panel
winapi.amanithvgpanel opengl + openvg-enabled panel using AmanithVG GLE implementation
winapi.cairopanel self:on_render(surface) event to draw on a cairo pixman surface
winapi.cairosgpanel cairo scene graph panel: call self.scene_graph:render(scene)
on self:on_render() to render a cairo scene graph


winapi = require'winapi'

local main = winapi.Window{
   title = 'Demo',
   w = 600, h = 400,
   autoquit = true,


Tip: The oo modules can be run as standalone scripts, which will showcase the module's functionality.


There's no method-by-method documentation, but there's a tech doc, a dev doc, and a narrative which should give you more context. The code is also well documented IMHO, including API quirks and empirical knowledge. Also, oo modules have a small runnable demo at the bottom of the file which showcases the module's functionality. Run the module as a standalone script to check it out.