?? luaddx.cpp
字號:
#include "stdafx.h"
#include "lua.h"
#undef DDX_Text
extern lua_State * lua;
void Lua_DDX_Text(CDataExchange *pDX, int nIDC, int &x)
{
// if initializing things, just call DDX_Text in the
// usual way...
if (pDX->m_bSaveAndValidate==FALSE)
DDX_Text(pDX, nIDC, x);
// otherwise, side-track things by sending the contents
// to Lua, processing them, and then stripping off the results;
else{
CString tolua;
int i,k;
DDX_Text(pDX, nIDC, tolua);
tolua="return " + tolua;
i=lua_gettop(lua);
lua_dostring(lua,tolua);
k=lua_gettop(lua);
if (i!=k){
tolua=lua_tostring(lua,-1);
if (tolua.GetLength()==0){
AfxMessageBox("Input does not evaluate to a numerical value");
pDX->Fail();
}
else x=(int)lua_tonumber(lua,-1);
else pDX->Fail();
}
}
void Lua_DDX_Text(CDataExchange* pDX, int nIDC, CString& value)
{
DDX_Text(pDX, nIDC, value);
}
void Lua_DDX_Text(CDataExchange *pDX, int nIDC, double &x)
{
// if initializing things, just call DDX_Text in the
// usual way...
if (pDX->m_bSaveAndValidate==FALSE)
DDX_Text(pDX, nIDC, x);
// otherwise, side-track things by sending the contents
// to Lua, processing them, and then stripping off the results;
else{
CString tolua;
int i,k;
tolua="return " + tolua;
i=lua_gettop(lua);
lua_dostring(lua,tolua);
k=lua_gettop(lua);
if (i!=k){
tolua=lua_tostring(lua,-1);
if (tolua.GetLength()==0){
AfxMessageBox("Input does not evaluate to a numerical value");
pDX->Fail();
}
else x=lua_tonumber(lua,-1);
}
else pDX->Fail();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -