-- ************************ -- -- Form and Controls Design -- -- ************************ -- myForm = VCL.Form("myForm") myForm._ = { caption="Run.Lua", width=300, height=200, position="poDesktopCenter", onMinimize="onMinimize", onMaximize="onMaximize"} myCB = VCL.CheckBox(myForm,"myCB") myCB._ = { caption="Minimize to tray", left=40, top=40, width = 200, onclick="onCBClick" } myCB2 = VCL.CheckBox(myForm,"myCB2") myCB2._ = { caption="Hide from taskbar", left=40, top=70, width = 200, onclick="onCB2Click" } ti = VCL.TrayIcon(myForm,"TI") ti._ = { enabled = false, hint="This is a balloon hint", showhint=true, cycleicons = false, ondblclick="onTrayIconDoubleClick", onCycle = "onCycle", onBalloonHintClick="onHintClick" } local traylib = medialib.."tray/" ImgList = VCL.ImageList(myForm,"ImgList") list_loadimgbuffer(ImgList,traylib.."0.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."1.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."2.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."3.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."4.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."5.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."6.bmp",VCL.clFuchsia) list_loadimgbuffer(ImgList,traylib.."7.bmp",VCL.clFuchsia) ti:Images(ImgList) -- ************************ -- -- Events -- -- ************************ -- function onMinimize() myForm.WindowState = "wsMinimized" if myCB2.checked == true then ti:HideMainForm() ti:HideTaskbarIcon() end if myCB.checked == true then ti.enabled = true ti.iconvisible = true ti.cycleinterval = 200 ti.cycleicons = true ti:ShowBalloonHint("Information", "Ballonhint icon types are: \n" .. "bitNone, bitInfo, bitWarning, bitError, bitCustom ", "bitInfo", 3) ti:Refresh() end end function onMaximize() if myForm.WindowState == "wsMaximized" then myForm.WindowState = "wsNormal" else myForm.WindowState = "wsMaximized" end end function onCBClick() end function onCB2Click() if myCB2.checked == true then myCB.checked = true end end function onCycle(Sender, NextIndex) ti.IconIndex = NextIndex end function onTrayIconDoubleClick() myForm.WindowState = "wsNormal" if myCB2.checked == true then ti:ShowMainForm() ti:ShowTaskbarIcon() end if myCB.checked == true then ti.enabled = false ti.iconvisible = false ti.cycleicons = false ti:Refresh() end end function onHintClick() onTrayIconDoubleClick() VCL.ShowMessage("Balloon Hint Clicked!") end function onMenuExit() ti:ShowMainForm() ti:ShowTaskbarIcon() myForm:Close() end -- ************************ -- -- Menu -- -- ************************ -- local traymenu = { {name="mm1",caption="Restore form", onclick="onTrayIconDoubleClick"}, {name="mm2",caption="-"}, {name="mm3",caption="Blah"}, {name="mm4",caption="Clah"}, {name="mm5",caption="Dlah"}, {name="mm6",caption="Exit", onclick="onMenuExit"} } local myPopup = VCL.PopupMenu(myForm,"myPopup") myPopup:Load(traymenu) ti.popupmenu = myPopup -- ti.leftpopup = true -- ************************ -- -- Main -- -- ************************ -- local p,n = resource.getfile(traylib.."run.ico") myForm:Icon(p,n) myForm:ShowModal() -- do not forget free trayicon object! ti:Free() -- vcldemo skips this form myForm:Free() myForm = nil ------------------------------------------------------------------------------