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
|
/* xkill.c
* Misnamed program which will kill whatever window is clicked on.
*/
#include <windows.h>
HWND me, target;
LRESULT CALLBACK
MainWindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
POINT pt;
WINDOWPLACEMENT wp;
switch (uMsg)
{
case WM_CREATE:
SetCapture (me);
break;
case WM_NCPAINT:
case WM_NCACTIVATE: /* prevent painting of nonclient areas */
return TRUE;
case WM_LBUTTONDOWN:
pt.x = LOWORD (lParam);
pt.y = HIWORD (lParam);
wp.length = sizeof (WINDOWPLACEMENT);
wp.flags = 0;
wp.showCmd = SW_MINIMIZE;
SetWindowPlacement (me, &wp);
target = WindowFromPoint (pt);
if (target == NULL) target = GetDesktopWindow ();
SendMessage (target, WM_CLOSE, 0, 0);
SendMessage (target, WM_DESTROY, 0, 0);
SendMessage (target, WM_QUIT, 0, 0);
wp.length = sizeof (WINDOWPLACEMENT);
wp.flags = 0;
wp.showCmd = SW_MAXIMIZE;
SetWindowPlacement (me, &wp);
break;
case WM_RBUTTONUP:
PostQuitMessage (0);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return 0;
}
int WINAPI
WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;
ZeroMemory (&wc, sizeof (WNDCLASS));
wc.lpfnWndProc = MainWindowProc;
wc.hInstance = hInst;
wc.hIcon = LoadIcon (hInst, "xkill_icon");
wc.hCursor = LoadCursor (hInst, "xkill_cursor");
wc.lpszClassName = "XKILL";
RegisterClass (&wc);
me = CreateWindowEx (WS_EX_TRANSPARENT, "XKILL", "XKill", 0,
0, -GetSystemMetrics (SM_CYCAPTION),
GetSystemMetrics (SM_CXSCREEN),
GetSystemMetrics (SM_CYSCREEN)
+ GetSystemMetrics (SM_CYCAPTION),
NULL, NULL, hInst, NULL);
ShowWindow (me, nCmdShow);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return (int)msg.wParam;
}
|