summaryrefslogtreecommitdiff
path: root/plugins/MagneticWindows/src/MagneticWindows.cpp
diff options
context:
space:
mode:
authorGoraf <goraf@miranda-ng.org>2013-10-11 20:53:23 +0000
committerGoraf <goraf@miranda-ng.org>2013-10-11 20:53:23 +0000
commit9b8ec8aeeb593644b053dc491818f37587293eae (patch)
tree0df68d63848d85b513db8a0f925e0b0e9fcf0ad2 /plugins/MagneticWindows/src/MagneticWindows.cpp
parentb4b33a756d9c5469007f3b4466a1cc21c6d2ddce (diff)
* adopted
* compilable version git-svn-id: http://svn.miranda-ng.org/main/trunk@6450 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MagneticWindows/src/MagneticWindows.cpp')
-rw-r--r--plugins/MagneticWindows/src/MagneticWindows.cpp161
1 files changed, 161 insertions, 0 deletions
diff --git a/plugins/MagneticWindows/src/MagneticWindows.cpp b/plugins/MagneticWindows/src/MagneticWindows.cpp
new file mode 100644
index 0000000000..80501cc80e
--- /dev/null
+++ b/plugins/MagneticWindows/src/MagneticWindows.cpp
@@ -0,0 +1,161 @@
+#include "MagneticWindowsCore.h"
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Magnetic Windows
+//
+// Autor: Michael Kunz
+// EMail: Michael.Kunz@s2005.tu-chemnitz.de
+//
+//
+// thanks to: pescuma
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Variables
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {08C01613-24C8-486F-BDAE-2C3DDCAF9347}
+ {0x8c01613, 0x24c8, 0x486f, { 0xbd, 0xae, 0x2c, 0x3d, 0xdc, 0xaf, 0x93, 0x47 }}
+};
+
+
+HANDLE hLoadedHook, hShootDownHook, hAddService, hRemService, hWindowEventHook;
+
+HINSTANCE hInst;
+int hLangpack;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// 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) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ mir_getLP(&pluginInfo);
+
+ 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
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+
+ return TRUE;
+}