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
|
#include "MagneticWindowsCore.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Magnetic Windows
//
// Autor: Michael Kunz
// EMail: Michael.Kunz@s2005.tu-chemnitz.de
//
//
// thanks to: pescuma
//
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// Variables
///////////////////////////////////////////////////////////////////////////////////////////////////
PLUGININFO pluginInfo = {
sizeof(PLUGININFO),
"Magnetic Windows",
PLUGIN_MAKE_VERSION(0,0,3,2),
"Makes the main contactlist and the chat windows snapping to the desktop border and to each other.",
"Michael Kunz",
"Michael.Kunz@s2005.TU-Cemnitz.de",
"(c) 2006 Michael Kunz",
"http://addons.miranda-im.org/details.php?action=viewfile&id=2871",
0,
0
};
PLUGINLINK * pluginLink;
HANDLE hLoadedHook, hShootDownHook, hAddService, hRemService, hWindowEventHook;
HINSTANCE hInst;
//char ModuleName[256];
char ModuleName[] = "MagneticWindows";
///////////////////////////////////////////////////////////////////////////////////////////////////
// Plugin Functions
///////////////////////////////////////////////////////////////////////////////////////////////////
//For other Plugins to start snapping for other Windows
int SnapPluginWindowStart(WPARAM wParam, LPARAM lParam) {
if (!WindowOpen((HWND)wParam)) return 1;
return 0;
}
//For other Plugins to stop snapping for other Windows
int SnapPluginWindowStop(WPARAM wParam, LPARAM lParam) {
if (!WindowClose((HWND)wParam)) return 1;
return 0;
}
int PluginMessageWindowEvent(WPARAM wParam, LPARAM lParam) {
MessageWindowEventData* Data;
HWND hWndParent, hWnd;
Data = (MessageWindowEventData*)(lParam);
switch (Data->uType) {
case MSG_WINDOW_EVT_OPEN:
hWnd = Data->hwndWindow;
//WindowOpen(hWnd);
hWndParent = GetParent(hWnd);
while ((hWndParent != 0) && (hWndParent != GetDesktopWindow()) && (IsWindowVisible(hWndParent))) {
hWnd = hWndParent;
hWndParent = GetParent(hWnd);
}
WindowOpen(hWnd);
break;
case MSG_WINDOW_EVT_CLOSING:
WindowClose(Data->hwndWindow);
break;
default:
break;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Main Functions
///////////////////////////////////////////////////////////////////////////////////////////////////
int SnapPluginStart(WPARAM wParam, LPARAM lParam) {
LoadOptions();
hWindowEventHook = HookEvent(ME_MSG_WINDOWEVENT, PluginMessageWindowEvent);
WindowOpen((HWND)CallService(MS_CLUI_GETHWND,0,0));
return 0;
}
int SnapPluginShootDown(WPARAM wParam, LPARAM lParam) {
UnhookEvent(hWindowEventHook);
UnhookEvent(hLoadedHook);
UnhookEvent(hShootDownHook);
UnhookEvent(hInitOptionsHook);
WindowCloseAll();
DestroyServiceFunction(hAddService);
DestroyServiceFunction(hRemService);
DestroyServiceFunction(hSnapToListService);
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Exportet Functions
///////////////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
{
return &pluginInfo;
}
extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
pluginLink = link;
hLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, SnapPluginStart);
hShootDownHook = HookEvent(ME_SYSTEM_PRESHUTDOWN, SnapPluginShootDown);
hInitOptionsHook = HookEvent(ME_OPT_INITIALISE, InitOptions);
hAddService = CreateServiceFunction(MS_MW_ADDWINDOW, SnapPluginWindowStart);
hRemService = CreateServiceFunction(MS_MW_REMWINDOW, SnapPluginWindowStop);
hSnapToListService = CreateServiceFunction(MS_MW_SNAPTOLIST, SnapToList);
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// DLL MAIN
///////////////////////////////////////////////////////////////////////////////////////////////////
extern "C" bool APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
hInst = hModule;
/* char * Temp;
char * l,i;
Temp = (char*) malloc(2048);
GetModuleFileName(hModule, Temp, 2048);
l = Temp;
i = Temp;
while (i != 0) {
if ((*i) == '\') l = i + 1;
i++;
}
memcpy(ModuleName, l, i-l);
free(Temp);
*/
return true;
}
|