lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Paul,

any idea how to implement that bellow, sent earlier?

On Thu, 14 May 2020 22:54:27 +0200, Procházka Lukáš Ing. <LPr@pontex.cz> wrote:

let's suppose the following minimalistic example (not tested), which is to provide GetConsoleWindow()'s (WinAPI) HWND to Lua as wxWidgets/Lua object (userdata):

---- MyLib.c
#include <lauxlib.h>
#include <lua.h>

#include <wx-something?>

int GetConsoleWindowsAsWxWindow(lua_State * L)
{ HWND wnd = GetConsoleWindow(); // WinAPI specific
   wxWindow * wxw = (wxWindow *) // GetWxWindowPointerFromHWND // What to come here?
   void * ud = lua_newuserdata(L, /* What to come here? */);
   // Probably a metatable to be assigned to 'ud' here

   return 1; // The userdata, being wxWidget actually
}

static luaL_Reg funs [] =
{ { "GetConsoleWindowsAsWxWindow", GetConsoleWindowsAsWxWindow },
   { NULL, NULL }
};

__declspec(dllexport) int luaopen_MyLib(lua_State * L)
{
   lua_newtable(L);
     luaL_setfuncs(L, funs, 0);
   lua_setglobal(L, "MyLib");

   return 0;
}
----

Best regards,

Lukas


--
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4

Mob.: +420 702 033 396