-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
492 lines (453 loc) · 16.2 KB
/
main.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#pragma comment(lib, "comctl32.lib")
#include "resource.h"
#include "tabs.h"
#include "services.h"
#include "ErrorParser.h"
// êîíòðîëíè êîäîâå
#define IOCTL_HIDE_FILE \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_OUT_DIRECT, FILE_READ_DATA | FILE_WRITE_DATA)
#define IOCTL_CLEAN_POOL \
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x801, METHOD_OUT_DIRECT, FILE_READ_DATA | FILE_WRITE_DATA)
BOOL CALLBACK MainHandler(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK TabHandler1(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK TabHandler2(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT APIENTRY SubClass_ListView_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// Ãëîáàëíè ïðîìåíëèâè
HINSTANCE hInst;
HWND hList = NULL; // Äðúæêà íà ñïèñúêà ñ ôàéëîâåòå
HWND hEdit = NULL; // Äðúæêà íà ðåäàêòîðíîòî ïîëå
char DriverName[50] = {0}; // Èìå íà äðàéâåðà
// Ãëàâíà ôóíêöèÿ
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwICC = ICC_LISTVIEW_CLASSES;
InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
if (InitCommonControlsEx(&InitCtrls)) {
hInst = hInstance;
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)MainHandler,0);
}
return EXIT_SUCCESS;
}
// Ãëàâíà ïðîöåäóðà
BOOL CALLBACK MainHandler(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam)
{
static HWND Window1, Window2;
static HWND TabWindow;
switch(Message)
{
case WM_INITDIALOG:
{
// Ñúçäàâàíå äâà äèàëîãà êàòî äåöà íà ãëàâíèÿ äèàëîã
Window1 = CreateDialog(hInst, MAKEINTRESOURCE(IID_TAB1), Window, &TabHandler1);
Window2 = CreateDialog(hInst, MAKEINTRESOURCE(IID_TAB2), Window, &TabHandler2);
// Èíèöèàëèçèðàíå íà TabWindow äðúæêà ñúñ ñúîòâåòíèÿ ðåñóðñ - TAB_MAIN
TabWindow = GetDlgItem(Window, TAB_MAIN);
// Ñúçäàâàíå íà ïúðâèÿ ðàçäåë (0 = ïðúâ)
AddTab(TabWindow, Window1, "Èíñòàëèðàíå Ñåðâèç", 0);
// Ñúçäàâàíå íà âòîðèÿ ðàçäåë
AddTab(TabWindow, Window2, "Ôàéëîâå", 1);
// Ïîêàçâàíå íà ïúðâèÿ ðàçäåë
TabToFront(TabWindow, 0);
}
break;
case WM_NOTIFY:
switch(((NMHDR *)lParam)->code)
{
case TCN_SELCHANGE: // Ïðè ïðîìÿíà íà ðàçäåëèòå...
{
char buf[50];
// Àêî òåêóùèÿ êîíòðîë å TabWindow
if (((LPNMHDR)lParam)->hwndFrom == TabWindow) {
// Äàëè å ñåëåêòèðàí âòîðèÿ ðàçäåë
if (SendMessage(((LPNMHDR)lParam)->hwndFrom,(UINT)TCM_GETCURFOCUS,0,0) == 1) {
GetDlgItemText(Window1, IDC_STATIC_STATUS, buf, 50);
// Äàëè äðàéâåðà å èíñòàëèðàí è ðàáîòè
if (strcmp("Installed And Running", buf) != 0) {
MessageBox(Window, "Äðàéâåðà òðÿáâà äà å ñòàðòóâàí", "FileHide", 0);
TabToFront(TabWindow, 0);
return FALSE;
}
}
// Ïîêàçâàíå íà ñëåäâàùèÿ ðàçäåë (àêî å ïîñëåäåí -> ïðúâ)
TabToFront(TabWindow, -1);
}
}
break;
default: return FALSE;
}
break;
case WM_CLOSE:
{
// Ïðàùàíå íà WM_CLOSE êúì âòîðèÿ äèàëîã çà ñòîïèðàíå è
// èçòðèâàíå íà äðàéâåðà, ïðåäè äà ñå èçêëþ÷è ïðîãðàìàòà
SendMessage(Window1, WM_CLOSE, 0, 0);
DestroyWindow(Window2);
DestroyWindow(Window1);
TabCleanup(TabWindow);
EndDialog(Window, 0);
}
break;
default:
return FALSE;
}
return TRUE;
}
// Ïðîöåäóðà íà ïúðâèÿ äèàëîã (ïúðâèÿ ðàçäåë)
BOOL CALLBACK TabHandler1(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam)
{
static HWND hComboBox;
const char *aServiceTypes[] = {"SERVICE_AUTO_START", "SERVICE_BOOT_START",
"SERVICE_DEMAND_START", "SERVICE_DISABLED",
"SERVICE_SYSTEM_START"};
static SC_HANDLE hSCManager;
char szFile[260];
switch(Message)
{
case WM_INITDIALOG:
{
int i;
// Èíèöèàëèçèðàíå íà êîìáî ïîëå îò ñúîòâåòíèÿ ðåñóðñ
hComboBox = GetDlgItem(Window, IDC_COMBO_TYPE);
for(i = 0; i < 5; i++) {
SendMessage(hComboBox, CB_ADDSTRING, 0, (LPARAM)aServiceTypes[i]);
}
// Ñåëåêòèðàíå íà òðåòèÿ åëåìåíò îò êîìáî-ñïèñúêú
SendMessage(hComboBox, CB_SETCURSEL, 2, 0);
// Èçêàðâàíå äðúæêà êúì SCM áàçàòà
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCManager == INVALID_HANDLE_VALUE) {
MessageBox(Window, GetErrorText(GetLastError()), "FileHide", MB_ICONERROR);
break;
}
}
break;
case WM_COMMAND:
{
switch(LOWORD(wParam)) {
case IDC_DRIVER_NAME_SELECT:
{
OPENFILENAME openFileDialog = {0};
char szExtendedFileName[260];
openFileDialog.lStructSize = sizeof(openFileDialog);
openFileDialog.hwndOwner = GetParent(Window);
openFileDialog.lpstrFilter = "Äðàéâåð(*.sys)\0*.SYS\0";
openFileDialog.nFilterIndex = 0;
openFileDialog.lpstrFileTitle = NULL;
openFileDialog.nMaxFileTitle = 0;
openFileDialog.lpstrInitialDir = NULL;
openFileDialog.lpstrFile = szFile;
openFileDialog.lpstrFile[0] = '\0';
openFileDialog.nMaxFile = sizeof(szFile);
openFileDialog.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// îòâàðàíå íà äèàëîã çà èçáîð íà *.sys ôàéë
if (GetOpenFileName(&openFileDialog)) {
// Ïúòå÷êàòà ñå ïðîìåíÿ ñ ðàçøèðåíà äúëæèíà
// ò.å. ñ ïðåäñòàâêà \\?\, çàùîòî äðàéâåðà íÿìà äà ðàáîòè ñ
// òàçè ïðîãðàìà àêî ñå íàìèðà â äðóãà ïàðòèöèÿ (ïðèìåð â D:\)
sprintf(szExtendedFileName,"\\\\?\\%s",szFile);
SetDlgItemText(Window, IDC_DRIVER_PATHNAME, szExtendedFileName);
// Èçâàæäàíå íà èìåòî íà äðàéâåðà îò öÿëàòà ïúòå÷êà, áåç ðàçøèðåíèåòî (.sys)
_splitpath(szFile, NULL, NULL, DriverName, NULL);
if (IsServiceInstalled(hSCManager, DriverName))
SetDlgItemText(Window, IDC_STATIC_STATUS, "Installed");
if (IsServiceRunning(Window, hSCManager, DriverName))
SetDlgItemText(Window, IDC_STATIC_STATUS, "Installed And Running");
}
}
break;
case IDC_BUT_INST:
{
DWORD startType = 0;
GetDlgItemText(Window, IDC_DRIVER_PATHNAME, szFile, 260);
// Èçâàæäàíå íà èìåòî íà äðàéâåðà îò öÿëàòà ïúòå÷êà, áåç ðàçøèðåíèåòî (.sys)
_splitpath(szFile, NULL, NULL, DriverName, NULL);
if (!strlen(DriverName)) {
MessageBox(Window, "Ïîëåòî çà äðàéâåðà å ïðàçíî", "FileHide", MB_ICONERROR);
break;
}
// Ïðîìÿíà íà startType â èçáðàíàòà ñòîéíîñò.
// Ïðåïîðú÷âà ñå SERVICE_DEMAND_START
switch (SendMessage(hComboBox, CB_GETCURSEL, 0, 0)) {
case 0: startType = SERVICE_AUTO_START; break;
case 1: startType = SERVICE_BOOT_START; break;
case 2: startType = SERVICE_DEMAND_START; break;
case 3: startType = SERVICE_DISABLED; break;
case 4: startType = SERVICE_SYSTEM_START; break;
}
// InstallServiceEx ñå íàìèðà â services.h
if (InstallServiceEx(Window, hSCManager, DriverName, startType, szFile))
SetDlgItemText(Window, IDC_STATIC_STATUS, "Installed");
}
break;
case IDC_BUT_UNINST:
{
GetDlgItemText(Window, IDC_DRIVER_PATHNAME, szFile, 260);
_splitpath(szFile, NULL, NULL, DriverName, NULL);
if (!strlen(DriverName)) {
MessageBox(Window, "Ïîëåòî çà äðàéâåðà å ïðàçíî", "FileHide", MB_ICONERROR);
break;
}
if (DeleteServiceEx(Window, hSCManager, DriverName))
SetDlgItemText(Window, IDC_STATIC_STATUS, "Uninstalled");
ZeroMemory(DriverName, sizeof(DriverName));
}
break;
case IDC_BUT_RUN:
{
GetDlgItemText(Window, IDC_DRIVER_PATHNAME, szFile, 260);
_splitpath(szFile, NULL, NULL, DriverName, NULL);
if (!strlen(DriverName)) {
MessageBox(Window, "Ïîëåòî çà äðàéâåðà å ïðàçíî", "FileHide", MB_ICONERROR);
break;
}
if (StartServiceEx(Window, hSCManager, DriverName))
SetDlgItemText(Window, IDC_STATIC_STATUS, "Installed And Running");
}
break;
case IDC_BUT_STOP:
{
GetDlgItemText(Window, IDC_DRIVER_PATHNAME, szFile, 260);
_splitpath(szFile, NULL, NULL, DriverName, NULL);
if (!strlen(DriverName)) {
MessageBox(Window, "Ïîëåòî çà äðàéâåðà å ïðàçíî", "FileHide", MB_ICONERROR);
break;
}
if (StopServiceEx(Window, hSCManager, DriverName))
SetDlgItemText(Window, IDC_STATIC_STATUS, "Installed");
ZeroMemory(DriverName, sizeof(DriverName));
}
break;
}
}
break;
case WM_CLOSE:
{
CloseServiceHandle(hSCManager);
}
break;
default:
return FALSE;
}
return TRUE;
}
BOOL CALLBACK TabHandler2(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam)
{
static int Index = -1;
static int lastEntry = 0;
static int flag = 0;
switch(Message)
{
case WM_LBUTTONDOWN:
// Àêî ïîòðåáèòåëÿ êëèêíå èçâúí ñïèñúêà ñ ôàéëîâå,
// ïðåêúñâà ñå ðåäàêòèðàíåòî íà ôàéëîâîòî èìå è âðúùà ñå ñòàðèÿ òåêñò
if (hEdit != NULL)
DestroyWindow(hEdit);
break;
case WM_INITDIALOG:
{
LVCOLUMN lvCol = {0};
LOGFONT logFont;
HFONT hFont;
// Èíèöèàëèçàöèÿ íà ñïèñúêà ñ ôàéëîâå,
// äîáàâÿíå íà òåêñòîâ ôîíò è çàãëàâèå íà êîëîíàòà
hList = GetDlgItem(Window, IDC_LISTVIEW);
memset(&logFont, 0, sizeof(LOGFONT));
logFont.lfHeight = 15;
strcpy(logFont.lfFaceName, "Courier New");
hFont = CreateFontIndirect(&logFont);
SendDlgItemMessage(Window, IDC_LISTVIEW, WM_SETFONT, (WPARAM)hFont, TRUE);
SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
lvCol.pszText = "";
lvCol.cx = 280;
SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&lvCol);
}
break;
case WM_NOTIFY: // Îáðàáîòêà íà ñúîáùåíèÿòà îò ñïèñúêú
switch(LOWORD(wParam)) {
case IDC_LISTVIEW:
{
if (((LPNMHDR)lParam)->code == NM_CLICK) { // Ëåâ êëèê âåäíúø â ñïèñúêúò
Index = SendMessage(hList, LVM_GETNEXTITEM, -1, LVIS_FOCUSED);
if (Index == -1) {
flag = 0;
break;
}
flag = 1;
break;
} else if (((LPNMHDR)lParam)->code == NM_DBLCLK) { // Ëåâ êëèê äâà ïúòè â ñïèñúêúò
if (hEdit != NULL)
DestroyWindow(hEdit);
// Àêî ïîòðåáèòåëÿ êëèêíå äâà ïúòè âúðõó ïðîçèâîëíî ôàéëîâî èìå
// ñå "ïîäêëàñâà" ñïèñúêúò:
{
RECT r;
WNDPROC wpOld;
LVITEM lvItem = {0};
char text[50] = "";
lvItem.mask = LVIF_TEXT;
lvItem.cchTextMax = 50;
lvItem.pszText = text;
SendMessage(hList, LVM_GETITEMTEXT, ((NMLISTVIEW*)lParam)->iItem, (LPARAM)&lvItem);
// Ïúðâî ñå íàìèðàò êîîðäèíàòèòå íà êúîøåòåòà íà ðåäàêòèðàùîòî ïîëå
ListView_GetSubItemRect(hList, ((NMLISTVIEW*)lParam)->iItem, 0, LVIR_LABEL, &r);
// Ñëåä òîâà ñå ñúçäàâà ðåäàêòèðàùî ïîëå âúðõó ëèíèÿòà, êîÿòî å ñåëåêòèðàíà
hEdit = CreateWindowEx(0, "EDIT", text, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT|ES_MULTILINE,
r.left, r.top, r.right-r.left, r.bottom-r.top,
((NMLISTVIEW*)lParam)->hdr.hwndFrom, NULL, hInst, 0);
SendMessage(hEdit, EM_LIMITTEXT, 50, 0); // Íå ïîâå÷å îò 50 áóêâè
SendMessage(hEdit, EM_SETSEL, 0, 50); // Òåêñòà ñå ñåëåêòèðà
SetFocus(hEdit); // Ðåäàêòèðàùîòî ïîëå ïîëó÷ÿâà ôîêóñ
// Çàìåíÿ ñå îáðàáîòâàùàòà ïðîöåäóðà íà ðåäàêòèðàùîòî ïîëå ñ SubClass_ListView_WndProc
wpOld = (WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, (LONG)SubClass_ListView_WndProc);
// Çàïàçâàò ñå íÿêîè âàæíè ñâîéñòâà ...
SetProp(hEdit, "WP_OLD", (HANDLE)wpOld);
SetProp(hEdit, "ITEM", (HANDLE)((NMLISTVIEW*)lParam)->iItem);
}
break;
} else if (((LPNMHDR)lParam)->code == NM_RCLICK) { // Äåñåí êëèê â ñïèñúêúò
// Ñúçäàâà ñå ìåíèòî ñ òðèòå áóòîíà "Äîáàâè", "Èçòðèé" è "Èçòðèé âñè÷êî"
HMENU hMenu = LoadMenu(NULL, MAKEINTRESOURCE(IDR_MENU));
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
POINT pt;
SetMenuDefaultItem(hPopupMenu, (UINT)-1, TRUE);
GetCursorPos(&pt);
SetForegroundWindow(Window);
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, Window, NULL);
SetForegroundWindow(Window);
// Èç÷èñòâàíå íà äðúæêèòå
DestroyMenu(hPopupMenu);
DestroyMenu(hMenu);
break;
}
}
break;
}
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case ID_ADD: // Äîáàâêà íà íîâî èìå â ñïèñúêúò
{
char text[50] = "";
LVITEM lvItem = {0}; // ListView Item struct
lvItem.mask = LVIF_TEXT; // Text Style
lvItem.cchTextMax = 50;
lvItem.iItem = SendMessage(hList, LVM_GETITEMCOUNT, 0, 0);
SendMessage(hList,LVM_INSERTITEM,0,(LPARAM)&lvItem);
sprintf(text,"FILENAMETOHIDE%d.EXE", lastEntry);
lvItem.pszText = text;
SendMessage(hList,LVM_SETITEM,0,(LPARAM)&lvItem);
lastEntry++;
break;
}
break;
case ID_REMOVE: // Èçòðèâàíå íà èìå îò ñïèñúêúò
if (flag)
SendMessage(hList, LVM_DELETEITEM, Index, 0);
flag = 0;
Index = -1;
break;
case ID_REMOVEALL: // Èçòðèâàíå íà âñè÷êè èìåíà îò ñïèñúêúò
SendMessage(hList, LVM_DELETEALLITEMS, 0, 0);
lastEntry = 0;
flag = 0;
Index = -1;
break;
case IDC_BUT_HIDE: // Áóòîíà çà ñêðèâàíå íà âñè÷êè èìåíà îò ñïèñúêúò
{
HANDLE hFile;
int i;
char drvName[50];
char fileName[50] = "";
char driverText[50] = "";
DWORD dwReturn;
LVITEM LvItem = {0};
// Ïðîâåðêà äàëè ñïèñúêúò å ïðàçåí
int count = SendMessage(hList, LVM_GETITEMCOUNT, 0, 0);
if (!count) {
MessageBox(Window, "Ïúðâî äîáàâè íÿêîëêó ôàéëà (ñ äåñåí êëèê).", "FileHide", 0);
break;
}
// Äîáàâÿíå íà ïðåòñòàâêà âúðõó èìåòî íà äðàéâåðà
// Òîâà âñúøíîñò å ñèìâîëè÷íîòî èìå íà äðàéâåðà
sprintf(drvName, "\\\\.\\%s", DriverName);
// Ñúçäàâàíå íà äðúæêà êúì äðàéâåðà çà ÷åòåíå è çàïèñ
hFile = CreateFile(drvName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
MessageBox(Window, GetErrorText(GetLastError()), "FileHide", MB_ICONERROR);
} else {
// Àêî å âñè÷êî íà ðåä, èçïðàùàìå êîíòðîëåí êîä IOCTL_CLEAN_POOL
// ñ áóôåð "clear pool", çà äà ñå èç÷èñòàò ïðåäèøíèòå ñêðèòè ôàéëîâå
DeviceIoControl(hFile, IOCTL_CLEAN_POOL, "clear pool", sizeof("clear pool"),
driverText, sizeof(driverText), &dwReturn, NULL);
LvItem.mask = LVIF_TEXT; // Text Style
LvItem.cchTextMax = 50;
LvItem.pszText = fileName;
// Îáõîæäà ñå ñïèñúêú è çà âñåêè îòäåëíî
// ñå èçïðàùà IOCTL_HIDE_FILE êîíòðîëåí êîä êúì äðàéâåðà
for (i=0; i<count; i++) {
LvItem.iItem = i;
SendMessage(hList, LVM_GETITEMTEXT, i, (LPARAM)&LvItem);
ZeroMemory(driverText, sizeof(driverText));
DeviceIoControl(hFile, IOCTL_HIDE_FILE, fileName, sizeof(fileName),
driverText, sizeof(driverText), &dwReturn, NULL);
MessageBox(Window, driverText, DriverName, 0);
//ZeroMemory(fileName, sizeof(fileName));
}
CloseHandle(hFile);
}
}
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
// Ïîäêëàñíà ïðîöåäóðà
LRESULT APIENTRY SubClass_ListView_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_KEYDOWN:
if (LOWORD(wParam) == VK_RETURN)
{
// Êîãàòî ÅNTER ñå íàòèñíå òðÿáâà äà ñå âìúêíå íàïèñàíèÿ òåêñò â ñïèñúêúò
LV_ITEM LvItem;
char text[50]="";
LvItem.iItem = (UINT)GetProp(hEdit, "ITEM"); // Ðåäîñëåäà íà èìåòî
LvItem.pszText = text;
// Íîâèÿ òåêñò îò ðåäàêòîðà ñå çàïèñâà â LvItem
GetWindowText(hEdit, text, sizeof(text));
// Çàïèñâàíåòî íà LvItem â ñïèñúêúò ñòàâà ÷ðåç LVM_SETITEMTEXT ñúîáùåíèåòî
SendMessage(hList, LVM_SETITEMTEXT, (WPARAM)GetProp(hEdit, "ITEM"), (LPARAM)&LvItem);
// Óíèùîæàâàíå íà ðåäàêòîðà
DestroyWindow(hEdit);
} else if (LOWORD(wParam) == VK_ESCAPE) // Àêî å íàòèñíàòî ESCAPE,
DestroyWindow(hEdit); // ïðåêúñâà ñå äåéñòâèåòî
break;
case WM_CHAR:
// Ïðàçíèòå ìåñòà íå ñà ïîçâîëåíè
if (LOWORD(wParam)==VK_SPACE || LOWORD(wParam)==VK_TAB)
return 0;
// Ïðåïðàâÿíå íà ìàëêèòå áóêâè â ãîëåìè
else if (LOWORD(wParam)>=97 && LOWORD(wParam)<=122)
wParam -= 32;
break;
case WM_DESTROY:
RemoveProp(hEdit, "WP_OLD");
RemoveProp(hEdit, "ITEM");
// Âúçâðúùàíå íà ïúðâè÷íàòà ïðîöåäóðà
SetWindowLong(hEdit, GWL_WNDPROC, (LONG)(WNDPROC)GetProp(hEdit, "WP_OLD"));
hEdit = NULL;
break;
}
// Âñè÷êî îñòàíàëî ìèíàâà
return CallWindowProc((WNDPROC)GetProp(hEdit, "WP_OLD"), hwnd, uMsg, wParam, lParam);
}
// Êðàé