-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwindowMsg.cpp
179 lines (168 loc) · 4.16 KB
/
windowMsg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include "stdafx.h"
#include "windowUniMod.h"
/*
====äëÿ ëèñòà êîìàíäû
0x400F - clear
0x400D - äîáàâèòü ñòðî÷êó
===íåïðîâåðåííî
0x4016 - äîñòàòü êàêîé-òî óêàçàòåëü, ìá ñòðî÷êó (ArgA - íîìåð)
====äëÿ ëèñòà ñîîáùåíèÿ -
0x4010 - ïðè âûäåëåíèè ñòðî÷êè
====äëÿ ýäèòà ñîîáùåíèÿ
0x401F - ïðè Enter
*/
namespace
{
int editBoxGetText(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || ((H->drawData.controlType & ctEditBox)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
wchar_t *R=(wchar_t*) noxCallWndProc(H,0x401D,0,0);///ñ÷èòàòü ñòðîêó
if(R==0)
{
lua_pushnil(L);
return 1;
}
int Len=wcslen(R);
char *Buf=new char[Len+1];
Buf[Len]=0;
wcstombs(Buf,R,Len);
lua_pushstring(L,Buf);
delete Buf;
return 1;
}
int editBoxSetText(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || lua_type(L,2)!=LUA_TSTRING || ((H->drawData.controlType & ctEditBox)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
size_t Len;
const char *R;
R=lua_tolstring(L,2,&Len);
if (R==NULL || Len==0)
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
wchar_t *Buf=new wchar_t[Len+1];
mbstowcs(Buf,R,Len);
Buf[Len]=0;
noxCallWndProc(H,0x401E,(int)(Buf),-1);///çàïèñàòü ñòðîêó
delete Buf;
lua_pushvalue(L,1);
return 1;
}
int buttonSetText(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || lua_type(L,2)!=LUA_TSTRING || ((H->drawData.controlType & ctPushButton)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
size_t Len;
const char *R;
R=lua_tolstring(L,2,&Len);
if (R==NULL)
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
wchar_t *Buf=new wchar_t[Len+1];
mbstowcs(Buf,R,Len);
Buf[Len]=0;
noxCallWndProc(H,0x4001,(int)(Buf),-1);///çàïèñàòü ñòðîêó
delete Buf;
lua_pushvalue(L,1);
return 1;
}
int ListBoxAddText(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || lua_type(L,2)!=LUA_TSTRING || ((H->drawData.controlType & ctListBox)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
size_t Len;
const char *R;
R=lua_tolstring(L,2,&Len);
if (R==NULL)
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
wchar_t *Buf=new wchar_t[Len+1];
mbstowcs(Buf,R,Len);
Buf[Len]=0;
noxCallWndProc(H,0x400D,(int)(Buf),-1);///çàïèñàòü ñòðîêó
delete Buf;
lua_pushvalue(L,1);
return 1;
}
int ListBoxClear(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || ((H->drawData.controlType & ctListBox)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
noxCallWndProc(H,0x400F,0,0);///Î÷èñòèòü ñïèñîê
return 0;
}
int ListBoxSetLine(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if ((H==0) || (lua_type(L,2)!=LUA_TNUMBER) || ((H->drawData.controlType & ctListBox)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
listBoxDataStruct *listBoxData=(listBoxDataStruct*) H->someData;
int idx=lua_tointeger(L,2);
if (idx>=-1 && idx<=listBoxData->maxLines)
listBoxData->lineSelectIdx=lua_tointeger(L,2);
return 0;
}
int buttonSwitchOff(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || ((H->drawData.controlType & ctPushButton)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
H->flags=(H->flags ^ (H->flags & wfEnabled));
return 0;
}
int buttonSwitchOn(lua_State *L)
{
wndStruct *H=wndGetHandleByLua(1);
if(H==0 || ((H->drawData.controlType & ctPushButton)==0))
{
lua_pushstring(L,"wrong args!");
lua_error(L);
}
H->flags|=wfEnabled;
return 0;
}
}
void windowMsgInit(lua_State*L)
{
registerclient("wndGetText",&editBoxGetText);
registerclient("wndSetText",&editBoxSetText);/// äëÿ ýäèòîâ
registerclient("wndLbAddText",&ListBoxAddText);/// äîáàâëÿåò ñòðî÷êó â ëèñòáîêñ
registerclient("wndLbClear",&ListBoxClear);
registerclient("wndLbSelectLine",&ListBoxSetLine);
registerclient("wndButtonSetText",&buttonSetText);
registerclient("wndButtonSwitchOn",&buttonSwitchOn);
registerclient("wndButtonSwitchOff",&buttonSwitchOff);
}