• Garry

    Hi Cosmin,

    First, thank you for the recent work you've done updating and documenting winapi.
    The new demo and docs make it a breeze to use.

    Second, I have done some work on finding out why the 64bit version of luajit doesn't work with winapi. I found that using version 2.0.4 of luajit raised some error messages which allowed me to do some detective work and I came up with the following changes in window.lua:-

    line 484 was:
    function GetWindowExStyle(hwnd) return GetWindowLong(hwnd, GWL_EXSTYLE) end
    I changed it to:
    function GetWindowExStyle(hwnd) return tonumber(GetWindowLong(hwnd, GWL_EXSTYLE)) end

    line 1214 was:
    local SC = bit.band(wParam, 0xfff0)
    I changed it to:
    local SC = bit.band(tonumber(wParam), 0xfff0)

    The error messages were complaining about functions expecting a number, but got cdata.
    These changes got rid of the error messages, but did not completely fix the problem.
    However I think it's closer to working now. Maybe these changes will give you a clue as to what else is wrong :)

    posted in General Discussion read more
  • Garry

    It's a great start!
    The usage examples are particularly useful ( for instance the one for windowclass ) as they point me in the right direction and help enormously in making sense of the detailed documentation.

    FYI - The links in your last post don't work for me. They take me to a "NOT FOUND" page. For some reason they take me to:-
    https://luapower.com/forum/winapi.windowclass
    instead of:-
    https://luapower.com/winapi.windowclass

    posted in General Discussion read more
  • Garry

    Ok, Thanks.

    Documenting winapi will be a huge task; I don't blame you for putting it off :)

    posted in General Discussion read more
  • Garry

    Hi,

    I've added the following code to my windows app:-

    function mywin.WM_LBUTTONDOWN(wParam, lParam)
    local x, y = splitsigned(lParam)
    print(x, y)
    end

    When I click the mouse, the value for x is correct, but the y value is always zero.
    Any ideas?

    Thanks.

    posted in General Discussion read more
  • Garry

    Got it! My app is now running with no dependencies. Thanks for all your help.

    posted in General Discussion read more
  • Garry

    Hi Cosmin

    As you have probably guessed I'm a bit of a noob at all this. I think most of my problems are due to my lack of experience. For instance, I've never used git before.

    So I tried the git method of installing Luapower and that worked fine. Now I have a full install with no missing files (that were the cause of my earlier problems.)

    However, I am still having issues creating a standalone .exe of my app.
    I can generate the .exe with a command:-
    .mgit/bundle.sh -M myapp -o test.exe
    but it turns out to have dependencies which I would rather avoid.
    For instance it's dependent on the winapi folder being preset.
    I can add individual winapi modules to the command, (with the -m option) but it seems I have to add nearly all of them to avoid the dependency. Is there an easier way to do this?

    My app also uses cairo and the resultant .exe is dependent on cairo.dll being present.
    I tried including the cairo static lib in the command (with the -a option) but that produced numerous errors. (mostly "undefined reference to" errors)

    Still learning :)

    Regards,
    Garry.

    posted in General Discussion read more
  • Garry

    Got it all working now - Thanks. And yes I did get multigit.

    Luapower is looking more and more like a great develoment system as my understanding of it improves. I like programming in Lua, and the utilities and packages that you have included make it a very complete setup for my needs.

    Thanks again.

    posted in General Discussion read more
  • Garry

    Hi,

    I'm trying to make a single exe app from a simple lua file, myapp.lua.
    After entering:-

    .mgit/bundle.sh -M myapp.lua - o test.exe

    I get:-

    .mgit.bundle.sh: line 423: .mgit/platform.sh: No such file or directory
    Unable to set platform.

    I checked the .mgit directory and there is no platform.sh file.
    Do I need to create it?

    I'm running on a 64bit windows machine, and using luapower-ming32.

    Thanks,
    Garry.

    posted in General Discussion read more
  • Garry

    Thanks, I'll check all of that out.

    posted in General Discussion read more
  • Garry

    I want to use the Polygon function in winapi (gdi.lua) and I note that it requires an array of cdata POINTs as its second argument. I can make this in my code with something like:-

    local pts = ffi.new("struct tagPOINT[" .. cnt .. "]") -- where cnt is the number of points

    but I was wondering if it would be better to change the Polygon function to accept a lua table of points to keep the application code cleaner and simpler. Something like:-

    function Polygon(hdc, points, cnt)
    local pts = ffi.new("struct tagPOINT[" .. cnt .. "]") -- an array of 'c' POINTs
    for i=1, cnt do
    pts[i-1].x=points[i][1] -- copy the points from points{} to pts[]
    pts[i-1].y=points[i][2]
    end
    return checknz(C.Polygon(hdc, pts, cnt)) end

    This adds the overhead of copying points from the lua table to the c array, but I suspect this is insignificant compared to actual task of drawing the polygon.
    This change would also apply to the PolyPolygon function.

    Secondly, I want to use the gdi line and curve drawing functions such as Polyline, LineTo, MoveTo etc, and I note that these don't seem to be implemented in gdi.lua.
    I think I can do it, but I guess I'm hoping that you have plans to add these yourself. :)

    Any thoughts?

    Thanks,
    Garry.

    posted in General Discussion read more
  • Garry

    The lack of docs doesn't bother me too much. The showcase examples provide a good starting point, and I'm happy to nut things out for myself if I can (I'm retired and have plenty of time on my hands).

    Thanks for the offer of further help. I'm sure I'll need it in the near future :)

    posted in General Discussion read more
  • Garry

    Perfect! Thanks for the quick response.

    posted in General Discussion read more
  • Garry

    Hi,
    Can you tell me how to set the background color of a winapi window?
    I've figured out that I can change the standard window background color with the following code:-

    local mywin = winapi.Window{
       title = "GARRY'S",
       background = winapi.ffi.cast('HBRUSH', 10),
       w = 600, h = 400, x=500, y=200,
       autoquit = true,
    }
    

    but I would a more general method that would allow any color such as:-
    background = 0xff0000 -- for a red background

    Any clues?
    Thanks,
    Garry.

    posted in General Discussion read more
Internal error.

Oops! Looks like something went wrong!