From 698a76547c0784b74218b2ca58dc44ee0c98c3ef Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 20 Mar 2013 19:15:04 +0000 Subject: starting adopr MsgPopup. git-svn-id: http://svn.miranda-ng.org/main/trunk@4132 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MsgPopup/MsgPopup_11.vcxproj | 195 ++++++++++++++++++++ plugins/MsgPopup/MsgPopup_11.vcxproj.filters | 41 +++++ plugins/MsgPopup/docs/MsgPopup.txt | 63 +++++++ plugins/MsgPopup/res/MsgPopup.rc | 133 ++++++++++++++ plugins/MsgPopup/src/common.h | 52 ++++++ plugins/MsgPopup/src/main.cpp | 258 +++++++++++++++++++++++++++ plugins/MsgPopup/src/options.cpp | 131 ++++++++++++++ plugins/MsgPopup/src/options.h | 22 +++ plugins/MsgPopup/src/resource.h | 34 ++++ 9 files changed, 929 insertions(+) create mode 100644 plugins/MsgPopup/MsgPopup_11.vcxproj create mode 100644 plugins/MsgPopup/MsgPopup_11.vcxproj.filters create mode 100644 plugins/MsgPopup/docs/MsgPopup.txt create mode 100644 plugins/MsgPopup/res/MsgPopup.rc create mode 100644 plugins/MsgPopup/src/common.h create mode 100644 plugins/MsgPopup/src/main.cpp create mode 100644 plugins/MsgPopup/src/options.cpp create mode 100644 plugins/MsgPopup/src/options.h create mode 100644 plugins/MsgPopup/src/resource.h (limited to 'plugins/MsgPopup') diff --git a/plugins/MsgPopup/MsgPopup_11.vcxproj b/plugins/MsgPopup/MsgPopup_11.vcxproj new file mode 100644 index 0000000000..dba3b5d928 --- /dev/null +++ b/plugins/MsgPopup/MsgPopup_11.vcxproj @@ -0,0 +1,195 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {1E702CF1-E52F-49F8-915A-FCBBCE554774} + MsgPopup + + + + DynamicLibrary + v110_xp + MultiByte + true + + + DynamicLibrary + v110_xp + MultiByte + true + + + DynamicLibrary + v110_xp + MultiByte + + + DynamicLibrary + v110_xp + MultiByte + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + MultiThreadedDebugDLL + false + Disabled + Level3 + true + EditAndContinue + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + ..\..\include;%(AdditionalIncludeDirectories) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + true + true + Windows + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin11\lib + false + dbghelp.lib;%(AdditionalDependencies) + + + + + MultiThreadedDebugDLL + false + Disabled + Level3 + ProgramDatabase + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + ..\..\include;%(AdditionalIncludeDirectories) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + true + true + Windows + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin11\lib + false + dbghelp.lib;%(AdditionalDependencies) + + + + + true + true + Full + Level3 + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;%(AdditionalIncludeDirectories) + Size + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + true + Windows + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin11\lib + false + true + true + true + /PDBALTPATH:%_PDB% %(AdditionalOptions) + dbghelp.lib;%(AdditionalDependencies) + + + + + true + true + Full + Level3 + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\..\include;%(AdditionalIncludeDirectories) + Size + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + true + Windows + $(IntDir)$(TargetName).lib + $(ProfileDir)..\..\bin11\lib + false + true + true + true + /PDBALTPATH:%_PDB% %(AdditionalOptions) + dbghelp.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/MsgPopup/MsgPopup_11.vcxproj.filters b/plugins/MsgPopup/MsgPopup_11.vcxproj.filters new file mode 100644 index 0000000000..20252c4830 --- /dev/null +++ b/plugins/MsgPopup/MsgPopup_11.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {f483e746-3653-4929-887e-f79771cb81d9} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {c09436c7-f2f3-4466-8985-3b1de6be34e0} + h;hpp;hxx;hm;inl + + + {dfa4551f-3ded-444a-8b03-f2a42739761e} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/MsgPopup/docs/MsgPopup.txt b/plugins/MsgPopup/docs/MsgPopup.txt new file mode 100644 index 0000000000..5b99aed133 --- /dev/null +++ b/plugins/MsgPopup/docs/MsgPopup.txt @@ -0,0 +1,63 @@ +"MessageBox -> Popup" plugin +========================== + +MsgBox.dll +version 0.0.0.1 +by StDenis, ICQ#337380210 + +Miranda 0.3.3+ recommended + +License info +------------ +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Description +----------- + +I dunno how MessageBoxes act on you, but I'm tired of them. +So I make a plugin which replace MessageBoxes with single OK button +into popups. + +*** CAUTION! *** +This plugin use non-ordinary technique - intercepting of API functions. +Author made all his best to provide compatibility and stability, but as usual: + +THIS STUFF PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +Known bugs & limitations & ToDo's: +---------------------------------- + - There's no chance to test this plugin under consumer's version of Windows + (Win9x, WinME) carefully. It was tested on only one PC, which may didn't + reflect all specificity of these versions of OS. + +Thanx to: +--------- + I'm glad to say thanks to HeikoH. Who helps me to test this plugin and + provide compatibility with consumer's Windoze. + +Changelog +--------- ++ - Added, +- - Fixed, +* - Changed. + +Version 0.0.0.1 +--------------- + + Initial release. diff --git a/plugins/MsgPopup/res/MsgPopup.rc b/plugins/MsgPopup/res/MsgPopup.rc new file mode 100644 index 0000000000..5b45a81bd2 --- /dev/null +++ b/plugins/MsgPopup/res/MsgPopup.rc @@ -0,0 +1,133 @@ +//Microsoft Developer Studio generated resource script. +// +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "..\src\resource.h" +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONS DIALOGEX 0, 0, 295, 181 +STYLE DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "",IDC_ASTERISK_FG,"ColourPicker",WS_GROUP | WS_TABSTOP, + 56,16,39,12,WS_EX_NOPARENTNOTIFY + GROUPBOX "ASTERISK style",IDC_STATIC,0,1,295,37 + LTEXT "Background",IDC_STATIC,113,18,40,8 + LTEXT "Foreground",IDC_STATIC,8,18,37,8 + CONTROL "",IDC_ASTERISK_BG,"ColourPicker",WS_GROUP | WS_TABSTOP, + 161,16,39,12,WS_EX_NOPARENTNOTIFY + CONTROL "",IDC_ERROR_FG,"ColourPicker",WS_GROUP | WS_TABSTOP,56, + 56,39,12,WS_EX_NOPARENTNOTIFY + GROUPBOX "ERROR style",IDC_STATIC,0,41,295,37 + LTEXT "Background",IDC_STATIC,113,58,40,8 + LTEXT "Foreground",IDC_STATIC,8,58,37,8 + CONTROL "",IDC_ERROR_BG,"ColourPicker",WS_GROUP | WS_TABSTOP,161, + 56,39,12,WS_EX_NOPARENTNOTIFY + CONTROL "",IDC_EXCLAMATION_FG,"ColourPicker",WS_GROUP | + WS_TABSTOP,56,96,39,12,WS_EX_NOPARENTNOTIFY + GROUPBOX "EXCLAMATION style",IDC_STATIC,0,81,295,37 + LTEXT "Background",IDC_STATIC,113,98,40,8 + LTEXT "Foreground",IDC_STATIC,8,98,37,8 + CONTROL "",IDC_EXCLAMATION_BG,"ColourPicker",WS_GROUP | + WS_TABSTOP,161,96,39,12,WS_EX_NOPARENTNOTIFY + CONTROL "",IDC_QUESTION_FG,"ColourPicker",WS_GROUP | WS_TABSTOP, + 56,136,39,12,WS_EX_NOPARENTNOTIFY + GROUPBOX "QUESTION style",IDC_STATIC,0,121,295,37 + LTEXT "Background",IDC_STATIC,113,138,40,8 + LTEXT "Foreground",IDC_STATIC,8,138,37,8 + CONTROL "",IDC_QUESTION_BG,"ColourPicker",WS_GROUP | WS_TABSTOP, + 161,136,39,12,WS_EX_NOPARENTNOTIFY + PUSHBUTTON "Preview",IDC_PREVIEW,234,162,50,14 + LTEXT "Timeout",IDC_STATIC,213,18,26,8 + EDITTEXT IDC_TIMEOUT1,245,15,40,14,ES_AUTOHSCROLL + LTEXT "Special values of the ""Timeout"":\n -1 - infinity, 0 - use default timeout value", + IDC_STATIC,17,160,137,18 + LTEXT "Timeout",IDC_STATIC,213,58,26,8 + EDITTEXT IDC_TIMEOUT2,245,55,40,14,ES_AUTOHSCROLL + LTEXT "Timeout",IDC_STATIC,213,98,26,8 + EDITTEXT IDC_TIMEOUT3,245,95,40,14,ES_AUTOHSCROLL + LTEXT "Timeout",IDC_STATIC,213,138,26,8 + EDITTEXT IDC_TIMEOUT4,245,135,40,14,ES_AUTOHSCROLL + CONTROL "Emit a sound",IDC_MESSAGEBEEP,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,167,164,57,10 +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_OPTIONS, DIALOG + BEGIN + RIGHTMARGIN, 222 + BOTTOMMARGIN, 179 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/MsgPopup/src/common.h b/plugins/MsgPopup/src/common.h new file mode 100644 index 0000000000..fbff74293b --- /dev/null +++ b/plugins/MsgPopup/src/common.h @@ -0,0 +1,52 @@ +/* + +MessagePopup - replacer of MessageBox'es + +Copyright 2004 Denis Stanishevskiy + +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include +#include +#include + +#include "newpluginapi.h" +#include "m_system.h" +#include "m_database.h" +#include "m_langpack.h" +#include "m_clist.h" +#include "m_options.h" +#include "m_utils.h" +#include "m_popup.h" + +#include "options.h" +#include "resource.h" + +#define SERVICENAME "MessagePopup" + +struct MSGBOXOPTIONS +{ + COLORREF FG[4]; + COLORREF BG[4]; + int Timeout[4]; + BOOL Sound; +}; + +extern MSGBOXOPTIONS options; +extern MSGBOXOPTIONS optionsDefault; + +void LoadConfig(); diff --git a/plugins/MsgPopup/src/main.cpp b/plugins/MsgPopup/src/main.cpp new file mode 100644 index 0000000000..bed3764b52 --- /dev/null +++ b/plugins/MsgPopup/src/main.cpp @@ -0,0 +1,258 @@ +/* + +MessagePopup - replacer of MessageBox'es + +Copyright 2004 Denis Stanishevskiy + +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +#include "common.h" + +HINSTANCE hInst; +int hLangpack; + +MSGBOXOPTIONS optionsDefault = +{ + {0, 0xFFFFFF, 0, 0}, + {0xBFFFFF, 0x0000FF, 0xB0B0FF, 0xECFF93}, + {-1,-1,-1,-1}, + TRUE +}; +MSGBOXOPTIONS options; + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + SERVICENAME, + PLUGIN_MAKE_VERSION( 0,0,0,1 ), + "This stuff will replace MessageBox'es [whose have only OK button] into Popups", + "Denis Stanishevskiy // StDenis", + "stdenformiranda(at)fromru(dot)com", + "Copyright (c) 2004, Denis Stanishevskiy", + "", + 0, 0 +}; + +typedef int (WINAPI *MSGBOXPROC)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType); + +MSGBOXPROC prevMessageBoxA; + +#define OIC_HAND 32513 +#define OIC_QUES 32514 +#define OIC_BANG 32515 +#define OIC_NOTE 32516 + +void popupMessage(LPCSTR lpText, LPCSTR lpCaption, UINT uType) +{ + POPUPDATAT ppd = {0}; + int iIcon; + int indx; + + switch(uType & 0xF0) + { + case MB_ICONHAND: + indx = 1; + iIcon = OIC_HAND; + break; + case MB_ICONEXCLAMATION: + indx = 2; + iIcon = OIC_BANG; + break; + case MB_ICONQUESTION: + indx = 3; + iIcon = OIC_QUES; + break; + default: + indx = 0; + iIcon = OIC_NOTE; + break; + + } + ppd.colorBack = options.BG[indx]; + ppd.colorText = options.FG[indx]; + ppd.iSeconds = options.Timeout[indx]; + + ppd.lchIcon = (HICON)LoadImage(NULL, MAKEINTRESOURCE(iIcon), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, LR_SHARED); + lstrcpy(ppd.lpzContactName, lpCaption); + lstrcpy(ppd.lpzText, lpText); + PUAddPopUpT(&ppd); + if(options.Sound) + MessageBeep(uType); +} + +int WINAPI newMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) +{ + if(CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) == CALLSERVICE_NOTFOUND || (uType & 0x0F)) + return prevMessageBoxA(hWnd, lpText, lpCaption, uType); + + popupMessage(lpText, lpCaption,uType); + return IDOK; +} + +BOOL g_HookError = FALSE; +BOOL g_HookError2 = FALSE; +int g_mod = 0; + +void HookOnImport(HMODULE hModule, char *lpszImpModName, DWORD lpOrigFunc, DWORD lpNewFunc) +{ + ULONG ulSize; + PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData( + hModule, + TRUE, + IMAGE_DIRECTORY_ENTRY_IMPORT, + &ulSize); + if(pImportDesc == NULL) return; + + for(; pImportDesc->Name; pImportDesc++) + { + char *pszModName = (char *)((PBYTE)hModule + pImportDesc->Name); + + if (lstrcmpiA(lpszImpModName, pszModName) == 0) + { + PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA)((PBYTE)hModule + pImportDesc->FirstThunk); + + for (; pThunk->u1.Function; pThunk++) + { + DWORD* ppfn = (DWORD*) &pThunk->u1.Function; + + if(*ppfn == lpOrigFunc) + { + DWORD oldProtect; + + g_mod++; + + if(!VirtualProtect((LPVOID)ppfn, 4, PAGE_EXECUTE_READWRITE, &oldProtect)) + { + if(!g_HookError) + { + char buf[200]; + + g_HookError = TRUE; + wsprintf(buf, "VirtualProtect failed. Code %d\n" + "Try to call the author", GetLastError()); + prevMessageBoxA(0, buf, "MsgBox", MB_OK); + } + } + *(DWORD*)ppfn = lpNewFunc; + if(*(DWORD*)ppfn != lpNewFunc) + { + if(!g_HookError2) + { + g_HookError2 = TRUE; + prevMessageBoxA(0, "Hmm. Something goes wrong. I can't write into the memory.\n" + "And as u can c, there are no any exception raised..\n" + "Try to call the author", "MsgBox", MB_OK); + } + } + } + } + } + } +} + +void HookAPI() +{ + DWORD lpMessageBox = (DWORD)GetProcAddress(GetModuleHandle("USER32.DLL"), "MessageBoxA"); + DWORD lpPopupMsgBox = (DWORD)newMessageBoxA; + + prevMessageBoxA = (MSGBOXPROC)lpMessageBox; + + BOOL bFound = FALSE; + HANDLE hModuleSnap = NULL; + MODULEENTRY32 me32 = {0}; + + hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId()); + if(hModuleSnap == INVALID_HANDLE_VALUE) + return; + + me32.dwSize = sizeof(MODULEENTRY32); + if(Module32First(hModuleSnap, &me32)) + { + do + { + HookOnImport(me32.hModule, "USER32.DLL", lpMessageBox, lpPopupMsgBox); + } + while (!bFound && Module32Next(hModuleSnap, &me32)); + } + CloseHandle (hModuleSnap); + + return; +} + +int HookedInit(WPARAM wParam, LPARAM lParam) +{ + HookAPI(); + + return 0; +} + +int HookedOptions(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS); + odp.ptszTitle = LPGENT("MessagePopup"); + odp.ptszGroup = LPGENT("Popups"); + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; + odp.pfnDlgProc = OptionsDlgProc; + Options_AddPage(wParam, &odp); + + return 0; +} + +void LoadConfig() +{ + char *szNameFG = "FGx"; + char *szNameBG = "BGx"; + char *szNameTO = "TOx"; + int indx; + + for(indx = 0; indx < 4; indx++) + { + szNameFG[2] = szNameBG[2] = szNameTO[2] = (char)(indx + '0'); + options.FG[indx] = DBGetContactSettingDword(NULL, SERVICENAME, szNameFG, optionsDefault.FG[indx]); + options.BG[indx] = DBGetContactSettingDword(NULL, SERVICENAME, szNameBG, optionsDefault.BG[indx]); + options.Timeout[indx] = DBGetContactSettingDword(NULL, SERVICENAME, szNameTO, (DWORD)optionsDefault.Timeout[indx]); + } + options.Sound = DBGetContactSettingByte(NULL, SERVICENAME, "Sound", (DWORD)optionsDefault.Sound); + +} +extern "C" __declspec(dllexport) int Load(void) +{ + mir_getLP(&pluginInfo); + HookEvent(ME_SYSTEM_MODULESLOADED, HookedInit); + HookEvent(ME_OPT_INITIALISE, HookedOptions); + + LoadConfig(); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} diff --git a/plugins/MsgPopup/src/options.cpp b/plugins/MsgPopup/src/options.cpp new file mode 100644 index 0000000000..b5467dcbe5 --- /dev/null +++ b/plugins/MsgPopup/src/options.cpp @@ -0,0 +1,131 @@ +/* + +MessagePopup - replacer of MessageBox'es + +Copyright 2004 Denis Stanishevskiy + +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +#include "common.h" + +int idOptionControls[4][3] = { + IDC_ASTERISK_FG,IDC_ASTERISK_BG,IDC_TIMEOUT1, + IDC_ERROR_FG,IDC_ERROR_BG,IDC_TIMEOUT2, + IDC_EXCLAMATION_FG,IDC_EXCLAMATION_BG,IDC_TIMEOUT3, + IDC_QUESTION_FG,IDC_QUESTION_BG,IDC_TIMEOUT4 +}; + +static int __inline DBWriteContactSettingDwordDef(HANDLE hContact,const char *szModule,const char *szSetting,DWORD val, DWORD defValue) +{ + if(val == DBGetContactSettingDword(hContact, szModule, szSetting, defValue)) + return 0; + else + return DBWriteContactSettingDword(hContact, szModule, szSetting, val); +} + +INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + { + int indx; + + TranslateDialogDefault(hWnd); + for(indx = 0; indx < 4; indx++) + { + SendDlgItemMessage(hWnd, idOptionControls[indx][0], CPM_SETCOLOUR, 0, options.FG[indx]); + SendDlgItemMessage(hWnd, idOptionControls[indx][1], CPM_SETCOLOUR, 0, options.BG[indx]); + SetDlgItemInt(hWnd, idOptionControls[indx][2], options.Timeout[indx], TRUE); + } + CheckDlgButton(hWnd, IDC_MESSAGEBEEP, options.Sound?BST_CHECKED:BST_UNCHECKED); + return TRUE; + } + case WM_COMMAND: + { + int indx, value; + BOOL Translated; + if(LOWORD(wParam) == IDC_PREVIEW) + { + MessageBoxA(0, Translate("Message with question"), Translate(SERVICENAME " - demo"), MB_ICONQUESTION); + MessageBoxA(0, Translate("Message with exclamation"), Translate(SERVICENAME " - demo"), MB_ICONEXCLAMATION); + MessageBoxA(0, Translate("Message with error"), Translate(SERVICENAME " - demo"), MB_ICONSTOP); + MessageBoxA(0, Translate("Message with asterisk"), Translate(SERVICENAME " - demo"), MB_ICONASTERISK); + + return FALSE; + } + if(LOWORD(wParam) == IDC_MESSAGEBEEP) + { + options.Sound = IsDlgButtonChecked(hWnd, IDC_MESSAGEBEEP) == BST_CHECKED; + } + else + for(indx = 0; indx < 4; indx++) + { + if(LOWORD(wParam) == idOptionControls[indx][0]) + { + if(HIWORD(wParam) != CPN_COLOURCHANGED) return FALSE; + options.FG[indx] = SendDlgItemMessage(hWnd, LOWORD(wParam), CPM_GETCOLOUR, 0, 0); + } + else + if(LOWORD(wParam) == idOptionControls[indx][1]) + { + if(HIWORD(wParam) != CPN_COLOURCHANGED) return FALSE; + options.BG[indx] = SendDlgItemMessage(hWnd, LOWORD(wParam), CPM_GETCOLOUR, 0, 0); + } + else + if(LOWORD(wParam) == idOptionControls[indx][2]) + { + if(HIWORD(wParam) != EN_CHANGE) return FALSE; + if((HWND)lParam != GetFocus()) return FALSE; + + value = (DWORD)GetDlgItemInt(hWnd, LOWORD(wParam), &Translated, TRUE); + if(Translated) options.Timeout[indx] = value; + } + } + SendMessage(GetParent(hWnd), PSM_CHANGED, 0,0); + break; + } + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->code) + { + case PSN_RESET: + LoadConfig(); + return FALSE; + + case PSN_APPLY: + { + char *szNameFG = "FGx"; + char *szNameBG = "BGx"; + char *szNameTO = "TOx"; + int indx; + + for(indx = 0; indx < 4; indx++) + { + szNameFG[2] = szNameBG[2] = szNameTO[2] = (char)(indx + '0'); + + DBWriteContactSettingDwordDef(NULL, SERVICENAME, szNameFG, options.FG[indx], optionsDefault.FG[indx]); + DBWriteContactSettingDwordDef(NULL, SERVICENAME, szNameBG, options.BG[indx], optionsDefault.BG[indx]); + DBWriteContactSettingDwordDef(NULL, SERVICENAME, szNameTO, options.Timeout[indx], (DWORD)optionsDefault.Timeout[indx]); + } + DBWriteContactSettingDwordDef(NULL,SERVICENAME,"Sound",options.Sound,optionsDefault.Sound); + + break; + } + } + break; + } + return FALSE; +} diff --git a/plugins/MsgPopup/src/options.h b/plugins/MsgPopup/src/options.h new file mode 100644 index 0000000000..07f81f28d9 --- /dev/null +++ b/plugins/MsgPopup/src/options.h @@ -0,0 +1,22 @@ +/* + +MessagePopup - replacer of MessageBox'es + +Copyright 2004 Denis Stanishevskiy + +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; either version 2 +of the License, or (at your option) any later version. + +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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ +INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/plugins/MsgPopup/src/resource.h b/plugins/MsgPopup/src/resource.h new file mode 100644 index 0000000000..27e128723b --- /dev/null +++ b/plugins/MsgPopup/src/resource.h @@ -0,0 +1,34 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by MsgBox.rc +// +#define IDD_OPTIONS 101 + +#define IDC_ASTERISK_BG 101 +#define IDC_ERROR_FG 102 +#define IDC_ERROR_BG 103 +#define IDC_EXCLAMATION_FG 104 +#define IDC_EXCLAMATION_BG 105 +#define IDC_QUESTION_FG 106 +#define IDC_QUESTION_BG 107 +#define IDC_ASTERISK_FG 108 +#define IDC_PREVIEW 109 + +#define IDC_TIMEOUT1 1000 +#define IDC_TIMEOUT2 1001 +#define IDC_TIMEOUT3 1002 +#define IDC_TIMEOUT4 1003 + +#define IDC_MESSAGEBEEP 1004 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 135 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3