Here is a basic app skeleton with menus, actions, toolbars etc.
-- VCLua Demo Application -- *************************************** -- VCLua 0.4.3 application -- Lua version 5.2.x required -- Copyright (C) 2014 Hi-Project Ltd. -- *************************************** _VCLUA_NAME = "VCLua Demo Application" _VCLUA_VERSION = "1.0" _VCLUA_APPID = "demo" package.cpath=package.cpath..";lib/?.dll;lib/?.so" require "vcl" mainForm = VCL.Form("mainform") mainForm._ = { icon="lua.ico", position="podesktopcenter", height=600, width=800, onclosequery="AppCloseQuery", caption=_VCLUA_NAME.." v".._VCLUA_VERSION} mainForm.windowstate = "wsMaximized" ------------------------------------------------------------------------------------------------ -- MainMenu functions ------------------------------------------------------------------------------------------------ function AppNew() EnableEvents() end function AppClose() DisableEvents() end function AppExit() mainForm:Close() end function AppCloseQuery(Sender) local ret = false if VCL.MessageDlg("Are you sure?","mtConfirmation",{"mbYes","mbCancel"})=="mrYes" then ret = true end return ret end function AppAbout() VCL.ShowMessage("About!") end function AppHelp() VCL.ShowMessage("Help!") end ---------------------------------------------------------------------------------------------- -- Images -- images should be in ./images folder -------------------------------------------------------------------------------------------------- local mainImages = VCL.ImageList() local images = { -- help "images/about.png", "images/help.png", -- file "images/new.png", "images/close.png", "images/exit.png", } mainImages:LoadFromTable(images) -------------------------------------------------------------------------------------------------- -- Actions -------------------------------------------------------------------------------------------------- local mainActions = VCL.ActionList() mainActions.Images = mainImages mainActions:LoadFromTable({ -- file {name="fileNewAction", onexecute="AppNew", caption="New", shortcut="Ctrl+N", imageIndex=2, hint="New file", }, {name="fileCloseAction", onexecute="AppClose", caption="&Close", shortcut="Ctrl+W", imageIndex=3, hint="Close file", }, {name="fileExitAction", onexecute="AppExit", caption="&Exit", shortcut="Alt+F4", imageIndex = 4, hint="Exit", }, -- help events {name="aboutAction", onexecute="AppAbout", caption="About ".._VCLUA_NAME.."...", imageindex=0, }, {name="helpAction", onexecute="AppHelp", caption="Help", shortcut="F1", imageindex=1, }, }) function DisableEvents() mainActions:Get("fileCloseAction").enabled = false end function EnableEvents() mainActions:Get("fileCloseAction").enabled = true end DisableEvents() -------------------------------------------------------------------------------------------------- -- MainMenu -------------------------------------------------------------------------------------------------- local mainMenu = VCL.MainMenu("mmmainmenu") mainMenu.Images = mainImages mainMenu.showhint=true mainMenu:LoadFromTable({ {name="mmfile", caption="&File", submenu={ {name="smnew", action=mainActions:Get("fileNewAction")}, {name="smclose", action=mainActions:Get("fileCloseAction")}, {caption="-",}, {name="smexit", action=mainActions:Get("fileExitAction")}, } }, {name="mmhelp", caption="&Help", RightJustify=true, submenu = { {name="mhabout", action=mainActions:Get("aboutAction")}, {caption="-",}, {name="mhhelp", action=mainActions:Get("helpAction")}, } } }) -------------------------------------------------------------------------------------------------- -- ToolBar -------------------------------------------------------------------------------------------------- local mainToolbar = VCL.ToolBar("maintoolbar") mainToolbar._ = { showhint=true, borderwidth =0, edgeborders = "[ebLeft,ebTop,ebRight,ebBottom]", edgeinner = "esRaised", edgeouter = "esLowered", autosize = true, buttonwidth = 24, buttonheight = 24, align = alTop, flat = true } mainToolbar.Images = mainImages mainToolbar:LoadFromTable({ {action=mainActions:Get("fileNewAction")}, {style="tbsDivider"}, {action=mainActions:Get("fileCloseAction")}, {style="tbsSeparator"}, }) -------------------------------------------------------------------------------------------------- -- StatusBar -------------------------------------------------------------------------------------------------- local mainStatusBar = VCL.StatusBar() mainStatusBar._ = {align="alBottom", height=100} for i=1,3 do mainStatusBar:Add(50+100*i/2,"") end -------------------------------------------------------------------------------------------------- -- Main -------------------------------------------------------------------------------------------------- mainForm:ShowModal() mainForm:Free()