diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-05-21 13:01:57 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-05-21 13:01:57 +0000 |
commit | e0771af6a53381f7dd826d2b6bee77c3610f15e0 (patch) | |
tree | b4d986f8d1f1a8f8e8dca2ccfbd11331c35145cf /plugins | |
parent | c29f535799abdb5a473b12206a3b390e474517ab (diff) |
plugin ZeroSwitch added. Works only under WinXP
git-svn-id: http://svn.miranda-ng.org/main/trunk@13731 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ZeroSwitch/ZeroSwitch.vcxproj | 28 | ||||
-rw-r--r-- | plugins/ZeroSwitch/ZeroSwitch.vcxproj.filters | 4 | ||||
-rw-r--r-- | plugins/ZeroSwitch/res/Version.rc | 38 | ||||
-rw-r--r-- | plugins/ZeroSwitch/src/ZeroSwitch.cpp | 154 | ||||
-rw-r--r-- | plugins/ZeroSwitch/src/stdafx.cxx | 18 | ||||
-rw-r--r-- | plugins/ZeroSwitch/src/stdafx.h | 16 | ||||
-rw-r--r-- | plugins/ZeroSwitch/src/version.h | 14 |
7 files changed, 272 insertions, 0 deletions
diff --git a/plugins/ZeroSwitch/ZeroSwitch.vcxproj b/plugins/ZeroSwitch/ZeroSwitch.vcxproj new file mode 100644 index 0000000000..f5562c11ad --- /dev/null +++ b/plugins/ZeroSwitch/ZeroSwitch.vcxproj @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{D31CD2B4-9025-4B01-9F74-EEEE2E94DDF4}</ProjectGuid>
+ <ProjectName>ZeroSwitch</ProjectName>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(ProjectDir)..\..\build\vc.common\common.props" />
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/ZeroSwitch/ZeroSwitch.vcxproj.filters b/plugins/ZeroSwitch/ZeroSwitch.vcxproj.filters new file mode 100644 index 0000000000..de5ad9f66c --- /dev/null +++ b/plugins/ZeroSwitch/ZeroSwitch.vcxproj.filters @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" />
+</Project>
\ No newline at end of file diff --git a/plugins/ZeroSwitch/res/Version.rc b/plugins/ZeroSwitch/res/Version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/plugins/ZeroSwitch/res/Version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "afxres.h"
+#include "..\src\version.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/plugins/ZeroSwitch/src/ZeroSwitch.cpp b/plugins/ZeroSwitch/src/ZeroSwitch.cpp new file mode 100644 index 0000000000..df460395c8 --- /dev/null +++ b/plugins/ZeroSwitch/src/ZeroSwitch.cpp @@ -0,0 +1,154 @@ +// ZeroSwitch.cpp : Defines the entry point for the DLL application.
+//
+
+#include "stdafx.h"
+
+HINSTANCE hInst;
+HHOOK hHook;
+HWND hDummyWnd = NULL, hHelperWnd = NULL, hMirandaWnd = NULL;
+int hLangpack;
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {3F1657B1-69CB-4992-9CFC-226C808A5202}
+ { 0x3f1657b1, 0x69cb, 0x4992, { 0x9c, 0xfc, 0x22, 0x6c, 0x80, 0x8a, 0x52, 0x2 } }
+};
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+LRESULT CALLBACK HelperProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_ACTIVATE:
+ if (LOWORD(wParam) != WA_INACTIVE) // Helper window got activated
+ SetActiveWindow(hMirandaWnd);
+ break;
+ case WM_DESTROY:
+ if (hWnd == hHelperWnd)
+ hHelperWnd = NULL;
+ else
+ hDummyWnd = NULL;
+ break;
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ return 0;
+}
+
+void CreateHelperWnd()
+{
+ WNDCLASSEX wcex;
+ // First we must check if Miranda's main window has the "Title bar" border style...
+ if ((GetWindowLongPtr(hMirandaWnd, GWL_STYLE) & WS_CAPTION) && !(GetWindowLongPtr(hMirandaWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW))
+ return;
+
+ if (hHelperWnd)
+ return; // We need only one helper window
+ // Widows taskbar workaround
+ // We don't want our helper window to be displayed on Windows taskbar.
+ // So firt of all we have to create an invisible window and then set it as
+ // parent to our window.
+
+ // Register windows class
+ wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = HelperProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInst;
+ wcex.hIcon = LoadSkinnedIconBig(SKINICON_OTHER_MIRANDA);
+ wcex.hCursor = NULL;
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+ wcex.lpszMenuName = NULL;
+ wcex.lpszClassName = _T("ZeroSwitchHlp");
+ wcex.hIconSm = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+
+ if (NULL == RegisterClassEx(&wcex))
+ return; // wtf
+
+ hDummyWnd = CreateWindow(_T("ZeroSwitchHlp"), _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
+ if (!hDummyWnd)
+ UnregisterClass(_T("ZeroSwitchHlp"), hInst);
+ hHelperWnd = CreateWindow(_T("ZeroSwitchHlp"), _T("Miranda NG"), WS_OVERLAPPEDWINDOW | WS_VISIBLE, -100, -100, 90, 90, hDummyWnd, NULL, hInst, NULL);
+ if (!hHelperWnd)
+ {
+ DestroyWindow(hDummyWnd);
+ UnregisterClass(_T("ZeroSwitchHlp"), hInst);
+ }
+}
+
+void DestroyHelperWnd()
+{
+ if (hHelperWnd)
+ {
+ DestroyWindow(hHelperWnd);
+ DestroyWindow(hDummyWnd);
+ UnregisterClass(_T("ZeroSwitchHlp"), hInst);
+ }
+}
+
+LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam)
+{
+ PCWPRETSTRUCT pMes;
+
+ if (nCode >= 0)
+ {
+ pMes = (PCWPRETSTRUCT)lParam; // Get message details
+ if (!hMirandaWnd)
+ hMirandaWnd = FindWindow(_T("Miranda"), NULL);
+
+ if (pMes->hwnd == hMirandaWnd)
+ {
+ if (pMes->message == WM_SHOWWINDOW) // We are interested only in this message
+ {
+ if (pMes->wParam == TRUE) // The window is being shown
+ CreateHelperWnd();
+ else
+ DestroyHelperWnd();
+ }
+ }
+ }
+ return CallNextHookEx(NULL, nCode, wParam, lParam); // Pass the message to other hooks in chain
+}
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ mir_getLP(&pluginInfo);
+
+ if (IsWinVerVistaPlus()) {
+ MessageBox(NULL, TranslateT("Plugin works under Windows XP only"), TranslateT("ZeroSwitch plugin failed"), MB_ICONSTOP);
+ return 1;
+ }
+
+ // Let's setup shop :)
+ hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, CallWndRetProc, NULL, GetCurrentThreadId());
+ if (hHook == NULL)
+ MessageBox(NULL, TranslateT("Oops, we've got a big hook error here :("), TranslateT("ZeroSwitch plugin failed"), MB_ICONSTOP);
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ if (hHook)
+ UnhookWindowsHookEx(hHook);
+ DestroyHelperWnd();
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/ZeroSwitch/src/stdafx.cxx b/plugins/ZeroSwitch/src/stdafx.cxx new file mode 100644 index 0000000000..6fb37564b7 --- /dev/null +++ b/plugins/ZeroSwitch/src/stdafx.cxx @@ -0,0 +1,18 @@ +/*
+Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
\ No newline at end of file diff --git a/plugins/ZeroSwitch/src/stdafx.h b/plugins/ZeroSwitch/src/stdafx.h new file mode 100644 index 0000000000..f5502963ee --- /dev/null +++ b/plugins/ZeroSwitch/src/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+#include <tchar.h>
+
+#include <newpluginapi.h>
+#include <m_clist.h>
+#include <m_skin.h>
+#include <m_langpack.h>
+
+#include "version.h"
diff --git a/plugins/ZeroSwitch/src/version.h b/plugins/ZeroSwitch/src/version.h new file mode 100644 index 0000000000..3e4fc66179 --- /dev/null +++ b/plugins/ZeroSwitch/src/version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 1
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "Zero switch"
+#define __FILENAME "ZeroSwitch.dll"
+#define __DESCRIPTION "Adds Miranda IM icon into Alt-Tab switch dialog even if Miranda's main window has style other Title bar."
+#define __AUTHOR "ZERO_BiT"
+#define __AUTHOREMAIL "zero-bit@mail.ru"
+#define __AUTHORWEB "http://miranda-ng.org/p/ZeroSwitch/"
+#define __COPYRIGHT "© 2007 ZERO_BiT"
|