lua-users home
lua-l archive

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


Hello Paul,

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;
}
----

On Wed, 13 May 2020 03:54:02 +0200, Paul K <paul@zerobrane.com> wrote:

Hi Lukas,

For some reason I assumed that the window would be part of
wxwidgets/wxlua app. If not, why not make the Windows API call instead
of wxwidgets?

So I have still the problem - how to create "wxWindow *" from HWND?

There is wxWindowMSW::SubclassWin(WXHWND hWnd) to convert a handle
into wxWindow, but it may not be available, even though you may have
access to methods that it uses, so you can implement the same logic
yourself.

2. It seems that "wxNativeWindow" or its functions are not exported in wxLua (working with "wxLua-2.8.12.3-Lua-5.1.5-MSW-Ansi.zip" here).

Yes, it's not available in wxlua, but shouldn't be difficult to add.
Let me know if you decide to try this path and I can add it to wxlua
in the repository I maintain (https://github.com/pkulchenko/wxlua).

Paul.


--
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
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org