[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: menu system for win32
- From: "Paul Winwood"<Paul_Winwood@...>
- Date: Mon, 19 Jul 1999 10:23:45 GMT
This is how I display a message box from LUA code embedded in my Windows app,
I am actually an earlier release of LUA, slightly modified, and compiled into a
DLL.
static void pr_messagebox (void)
{
int result;
lua_Object hwndFrame = lua_getglobal("hwndFrame");
assert (lua_isuserdata(hwndFrame));
char *pTitle = luaL_check_string (1);
char *pPrompt = luaL_check_string (2);
int iParam = (int) luaL_opt_number (3, 0);
int iIcon = (int) luaL_opt_number (4, 0);
int iType = 0;
switch (iParam)
{
default:
case 0:
iType = MB_OK;
break;
... more cases
}
switch (iIcon)
{
default:
case 0:
iType |= MB_ICONEXCLAMATION;
break;
.. more cases
}
result = MessageBox((HWND) lua_getuserdata(hwndFrame),
pPrompt,
pTitle,
iType);
lua_pushnumber ((float) result);
}
static struct luaL_reg messagelib[] =
{
...
{"MessageBox", pr_messagebox},
...
};
void message_open (void)
{
luaL_openlib (messagelib,
(sizeof (messagelib) / sizeof (messagelib[0])));
}
the function message_open() is called when the application is initializing to
add this function to lua as a c-function. the lua global 'hwndFrame' is set via
lua_setglobal() when the main window is created. In the lua code to display a
message box I then call 'MessageBox(prompt, title) or MessageBox(prompt, title,
param, icon) etc.
Hope this helps,
Paul.
______________________________ Reply Separator _________________________________
Subject: menu system for win32
Author: <lua-l@tecgraf.puc-rio.br> at INTERNET
Date: 19/07/99 02:20
I just found LUA a couple of days ago, and (hopefully) am going to use it to
support user definable menus in my win32 program.
The problem is I don't really know where to start with LUA. I've read the
manual, compiled it and have played around with the dos interpreter. (you
know done hello world, printed out the lyrics to the 99 bottle of beer
song,....)
so I was wondering if some one could help me get started with this. Does
anyone have a framework for a interpreter in win32 (c/c++ win32 would be
best MFC makes me queazy)? I'm sure if I could see an example of what is
needed to create a windows messagebox from a lua script run by a windows app
I would be set.
Thanks for reading,
Jeff
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com