Attempt to create a button with winapi


  • So I'm trying to create a simple button but I'm getting a error.

    Error: winapi/button.lua:175: non-zero expected, got zero
    stack traceback:
            [C]: in function 'error'
            winapi/util.lua:102: in function 'checknz'
            winapi/button.lua:175: in function 'Button_SetTextMargin'
            winapi/buttonclass.lua:52: in function <winapi/buttonclass.lua:48>
            winapi/vobject.lua:39: in function '__set_vproperty'
            winapi/vobject.lua:23: in function '__newindex'
            winapi/basewindowclass.lua:418: in function '__init'
            winapi/controlclass.lua:49: in function '__init'
            winapi/object.lua:32: in function 'Button'
            main.lua:14: in function 'load'
            [string "boot.lua"]:439: in function <[string "boot.lua"]:435>
            [C]: in function 'xpcall'
    

    This is the code I used.

    local winapi = require("winapi")
    require("winapi.windowclass")
    require("winapi.buttonclass")
    
    function love.load()
        local Window = winapi.Window {
            title = "löve compiler",
            autoquit = true,
            visible = true,
            w = 500,
            h = 300,
        }
        
        local Button = winapi.Button {
            text = "button",
            w = 300,
            h = 100,
            x = 50,
            y = 50,
            parent = Window
        }
    end
    

  • 2
    Posts
    746
    Views
    Log in to reply


  • @Alonso-Hermosilla said:

    So I'm trying to create a simple button but I'm getting a error.

    Error: winapi/button.lua:175: non-zero expected, got zero
    stack traceback:
            [C]: in function 'error'
            winapi/util.lua:102: in function 'checknz'
            winapi/button.lua:175: in function 'Button_SetTextMargin'
            winapi/buttonclass.lua:52: in function <winapi/buttonclass.lua:48>
            winapi/vobject.lua:39: in function '__set_vproperty'
            winapi/vobject.lua:23: in function '__newindex'
            winapi/basewindowclass.lua:418: in function '__init'
            winapi/controlclass.lua:49: in function '__init'
            winapi/object.lua:32: in function 'Button'
            main.lua:14: in function 'load'
            [string "boot.lua"]:439: in function <[string "boot.lua"]:435>
            [C]: in function 'xpcall'
    

    This is the code I used.

    local winapi = require("winapi")
    require("winapi.windowclass")
    require("winapi.buttonclass")
    
    function love.load()
      local Window = winapi.Window {
          title = "löve compiler",
          autoquit = true,
          visible = true,
          w = 500,
          h = 300,
      }
      
      local Button = winapi.Button {
          text = "button",
          w = 300,
          h = 100,
          x = 50,
          y = 50,
          parent = Window
      }
    end
    

    hope, you've already resolved this... but .... you just need to:

    local winapi = require("winapi")
    require("winapi.windowclass")
    require("winapi.buttonclass")
    
    local function main()
        local Window = winapi.Window {
            title = "löve compiler",
            autoquit = true,
            visible = true,
            w = 500,
            h = 300,
        }
        
        local Button = winapi.Button {
            text = "button",
            w = 300,
            h = 100,
            x = 50,
            y = 50,
            parent = Window
        }
    
        winapi.MessageLoop()
    end
    
    main()
    

2
Posts
746
Views
Log in to reply

Internal error.

Oops! Looks like something went wrong!