From 968d40dc006d57bf614f9522a9d262650beee4cc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 31 Oct 2013 18:16:31 +0000 Subject: - subclassing fix - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@6722 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MagneticWindows/src/MagneticWindows.cpp | 74 ++++++++++--------------- 1 file changed, 30 insertions(+), 44 deletions(-) (limited to 'plugins/MagneticWindows/src/MagneticWindows.cpp') diff --git a/plugins/MagneticWindows/src/MagneticWindows.cpp b/plugins/MagneticWindows/src/MagneticWindows.cpp index 80b05731c0..bcf38c3036 100644 --- a/plugins/MagneticWindows/src/MagneticWindows.cpp +++ b/plugins/MagneticWindows/src/MagneticWindows.cpp @@ -31,9 +31,6 @@ PLUGININFOEX pluginInfo = { {0x8c01613, 0x24c8, 0x486f, { 0xbd, 0xae, 0x2c, 0x3d, 0xdc, 0xaf, 0x93, 0x47 }} }; - -HANDLE hLoadedHook, hShootDownHook, hAddService, hRemService, hWindowEventHook; - HINSTANCE hInst; int hLangpack; @@ -43,42 +40,40 @@ int hLangpack; //For other Plugins to start snapping for other Windows -INT_PTR SnapPluginWindowStart(WPARAM wParam, LPARAM) { +INT_PTR SnapPluginWindowStart(WPARAM wParam, LPARAM) +{ if (!WindowOpen((HWND)wParam)) return 1; - return 0; } + //For other Plugins to stop snapping for other Windows -INT_PTR SnapPluginWindowStop(WPARAM wParam, LPARAM) { +INT_PTR SnapPluginWindowStop(WPARAM wParam, LPARAM) +{ if (!WindowClose((HWND)wParam)) return 1; - return 0; } -int PluginMessageWindowEvent(WPARAM, LPARAM lParam) { - HWND hWndParent, hWnd; - +int PluginMessageWindowEvent(WPARAM, LPARAM lParam) +{ MessageWindowEventData *Data = (MessageWindowEventData*) lParam; switch (Data->uType) { - case MSG_WINDOW_EVT_OPEN: - hWnd = Data->hwndWindow; - //WindowOpen(hWnd); - hWndParent = GetParent(hWnd); + case MSG_WINDOW_EVT_OPEN: + { + HWND hWnd = Data->hwndWindow; + 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; + } + break; + + case MSG_WINDOW_EVT_CLOSING: + WindowClose(Data->hwndWindow); + break; } return 0; @@ -89,28 +84,19 @@ int PluginMessageWindowEvent(WPARAM, LPARAM lParam) { // Main Functions /////////////////////////////////////////////////////////////////////////////////////////////////// - -int SnapPluginStart(WPARAM, LPARAM) { +int SnapPluginStart(WPARAM, LPARAM) +{ LoadOptions(); - hWindowEventHook = HookEvent(ME_MSG_WINDOWEVENT, PluginMessageWindowEvent); + HookEvent(ME_MSG_WINDOWEVENT, PluginMessageWindowEvent); WindowOpen((HWND)CallService(MS_CLUI_GETHWND,0,0)); return 0; } -int SnapPluginShootDown(WPARAM, LPARAM) { - UnhookEvent(hWindowEventHook); - UnhookEvent(hLoadedHook); - UnhookEvent(hShootDownHook); - UnhookEvent(hInitOptionsHook); - +int SnapPluginShutDown(WPARAM, LPARAM) +{ WindowCloseAll(); - - DestroyServiceFunction(hAddService); - DestroyServiceFunction(hRemService); - DestroyServiceFunction(hSnapToListService); - return 0; } @@ -128,14 +114,15 @@ extern "C" int __declspec(dllexport) Load() { mir_getLP(&pluginInfo); - hLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, SnapPluginStart); - hShootDownHook = HookEvent(ME_SYSTEM_PRESHUTDOWN, SnapPluginShootDown); - hInitOptionsHook = HookEvent(ME_OPT_INITIALISE, InitOptions); + HookEvent(ME_SYSTEM_MODULESLOADED, SnapPluginStart); + HookEvent(ME_SYSTEM_PRESHUTDOWN, SnapPluginShutDown); + HookEvent(ME_OPT_INITIALISE, InitOptions); - hAddService = CreateServiceFunction(MS_MW_ADDWINDOW, SnapPluginWindowStart); - hRemService = CreateServiceFunction(MS_MW_REMWINDOW, SnapPluginWindowStop); - hSnapToListService = CreateServiceFunction(MS_MW_SNAPTOLIST, SnapToList); + CreateServiceFunction(MS_MW_ADDWINDOW, SnapPluginWindowStart); + CreateServiceFunction(MS_MW_REMWINDOW, SnapPluginWindowStop); + CreateServiceFunction(MS_MW_SNAPTOLIST, SnapToList); + WindowStart(); return 0; } @@ -152,6 +139,5 @@ extern "C" int __declspec(dllexport) Unload() BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { hInst = hinstDLL; - - return TRUE; + return TRUE; } -- cgit v1.2.3