diff options
Diffstat (limited to 'plugins/Popup/src/main.cpp')
-rw-r--r-- | plugins/Popup/src/main.cpp | 193 |
1 files changed, 91 insertions, 102 deletions
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index 8272df4782..3680e6ee42 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -29,82 +29,72 @@ WORD SETTING_MAXIMUMWIDTH_MAX = GetSystemMetrics(SM_CXSCREEN); HANDLE hEventNotify;
-//===== MessageBoxes =====
-//void MB(char*); //This one is for Debug purposes
-//void Log(char*); //This one is used to notify the user
-//void HigherLower(int, int); //Used for integer input boxes (out of bound values).
-//void NotifyError(DWORD, char*, int, char*); //Used to notify an error giving some error codes to report.
-
-//===== Options =====
+//===== Options =========================================================================
static int OptionsInitialize(WPARAM,LPARAM);
void UpgradeDb();
-//===== Initializations =====
+//===== Initializations =================================================================
static int OkToExit(WPARAM,LPARAM);
bool OptionLoaded = false;
int hLangpack = 0;
-//===== Global variables =====
-//===== DLLs =====
-HMODULE hUserDll = 0;
-HMODULE hMsimgDll = 0;
-HMODULE hKernelDll = 0;
-HMODULE hGdiDll = 0;
-HMODULE hDwmapiDll = 0;
+//===== Global variables ================================================================
+HMODULE hUserDll = 0;
+HMODULE hMsimgDll = 0;
+HMODULE hKernelDll = 0;
+HMODULE hGdiDll = 0;
+HMODULE hDwmapiDll = 0;
-//===== User wnd class =====
GLOBAL_WND_CLASSES g_wndClass = {0};
-//===== MTextControl ====
-HANDLE htuText;
-HANDLE htuTitle;
+HANDLE htuText;
+HANDLE htuTitle;
-//===== Menu item =====
HGENMENU hMenuRoot;
HGENMENU hMenuItem;
HGENMENU hMenuItemHistory;
-//===== Event Handles =====
-HANDLE hTTButton;
+HANDLE hTTButton;
+
+//===== Options pages ===================================================================
-//===== Options pages =====
static int OptionsInitialize(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.position = 100000000;
+ odp.position = 100000000;
odp.groupPosition = 910000000;
- odp.hInstance = hInst;
- odp.flags = ODPF_BOLDGROUPS;
- odp.pszTitle = MODULNAME_PLU;
+ odp.hInstance = hInst;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszTitle = MODULNAME_PLU;
- odp.pszTab = LPGEN("General");
- odp.pfnDlgProc = DlgProcPopupGeneral;
+ odp.pszTab = LPGEN("General");
+ odp.pfnDlgProc = DlgProcPopupGeneral;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_POPUP_GENERAL);
Options_AddPage(wParam, &odp);
- odp.pszTab = LPGEN("Classes");
- odp.pfnDlgProc = DlgProcOptsClasses;
+ odp.pszTab = LPGEN("Classes");
+ odp.pfnDlgProc = DlgProcOptsClasses;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOTIFICATIONS);
Options_AddPage(wParam, &odp);
- odp.pszTab = LPGEN("Actions");
- odp.pfnDlgProc = DlgProcPopupActions;
+ odp.pszTab = LPGEN("Actions");
+ odp.pfnDlgProc = DlgProcPopupActions;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ACTIONS);
Options_AddPage(wParam, &odp);
- odp.pszTab = LPGEN("Contacts");
- odp.pfnDlgProc = DlgProcContactOpts;
+ odp.pszTab = LPGEN("Contacts");
+ odp.pfnDlgProc = DlgProcContactOpts;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CONTACTS);
Options_AddPage(wParam, &odp);
- odp.pszTab = LPGEN("Advanced");
- odp.pfnDlgProc = DlgProcPopupAdvOpts;
+ odp.pszTab = LPGEN("Advanced");
+ odp.pfnDlgProc = DlgProcPopupAdvOpts;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_POPUP_ADVANCED);
Options_AddPage(wParam, &odp);
- odp.pszGroup = LPGEN("Skins");
- odp.pszTab = LPGEN(MODULNAME_PLU);
- odp.pfnDlgProc = DlgProcPopSkinsOpts;
+ odp.pszGroup = LPGEN("Skins");
+ odp.pszTab = LPGEN(MODULNAME_PLU);
+ odp.pfnDlgProc = DlgProcPopSkinsOpts;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SKIN2);
Options_AddPage(wParam, &odp);
return 0;
@@ -121,12 +111,12 @@ static int IconsChanged(WPARAM, LPARAM) LoadActions();
CLISTMENUITEM mi = { sizeof(mi) };
- if (PopupOptions.ModuleIsEnabled == TRUE) { //The module is enabled.
- //The action to do is "disable popups" (show disabled) and we must write "enable popup" in the new item.
+ if (PopupOptions.ModuleIsEnabled == TRUE) { // The module is enabled.
+ // The action to do is "disable popups" (show disabled) and we must write "enable popup" in the new item.
mi.hIcon = IcoLib_GetIcon(ICO_POPUP_ON, 0);
}
- else { //The module is disabled.
- //The action to do is enable popups (show enabled), then write "disable popup" in the new item.
+ else { // The module is disabled.
+ // The action to do is enable popups (show enabled), then write "disable popup" in the new item.
mi.hIcon = IcoLib_GetIcon(ICO_POPUP_OFF, 0);
}
mi.flags = CMIM_ICON;
@@ -156,21 +146,21 @@ static int TTBLoaded(WPARAM, LPARAM) return 0;
}
-//===== EnableDisableMenuCommand =====
+//===== EnableDisableMenuCommand ========================================================
INT_PTR svcEnableDisableMenuCommand(WPARAM, LPARAM)
{
CLISTMENUITEM mi = { sizeof(mi) };
if (PopupOptions.ModuleIsEnabled) {
- //The module is enabled.
- //The action to do is "disable popups" (show disabled) and we must write "enable popup" in the new item.
+ // The module is enabled.
+ // The action to do is "disable popups" (show disabled) and we must write "enable popup" in the new item.
PopupOptions.ModuleIsEnabled = FALSE;
db_set_b(NULL, "Popup", "ModuleIsEnabled", FALSE);
mi.ptszName = LPGENT("Enable Popups");
mi.hIcon = IcoLib_GetIcon(ICO_POPUP_OFF,0);
}
else {
- //The module is disabled.
- //The action to do is enable popups (show enabled), then write "disable popup" in the new item.
+ // The module is disabled.
+ // The action to do is enable popups (show enabled), then write "disable popup" in the new item.
PopupOptions.ModuleIsEnabled = TRUE;
db_set_b(NULL, "Popup", "ModuleIsEnabled", TRUE);
mi.ptszName = LPGENT("Disable Popups");
@@ -197,42 +187,40 @@ void InitMenuItems(void) {
CLISTMENUITEM mi = { sizeof(mi) };
// support new genmenu style
- mi.flags = CMIF_ROOTHANDLE|CMIF_TCHAR;
- mi.hParentMenu = HGENMENU_ROOT;
+ mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
+ mi.hParentMenu = HGENMENU_ROOT;
// Build main menu
- mi.position = -1000000000 /*1000001*/;
- mi.ptszName = LPGENT(MODULNAME_PLU);
- mi.hIcon = IcoLib_GetIcon(PopupOptions.ModuleIsEnabled ? ICO_POPUP_ON : ICO_POPUP_OFF ,0);
- hMenuRoot = Menu_AddMainMenuItem(&mi);
+ mi.position = -1000000000 /*1000001*/;
+ mi.ptszName = LPGENT(MODULNAME_PLU);
+ mi.hIcon = IcoLib_GetIcon(PopupOptions.ModuleIsEnabled ? ICO_POPUP_ON : ICO_POPUP_OFF, 0);
+ hMenuRoot = Menu_AddMainMenuItem(&mi);
// Add item to main menu
- mi.hParentMenu = (HGENMENU)hMenuRoot;
+ mi.hParentMenu = (HGENMENU)hMenuRoot;
CreateServiceFunction(MENUCOMMAND_SVC, svcEnableDisableMenuCommand);
- mi.ptszName = PopupOptions.ModuleIsEnabled ? LPGENT("Disable Popups") : LPGENT("Enable Popups");
- mi.pszService = MENUCOMMAND_SVC;
- hMenuItem = Menu_AddMainMenuItem(&mi);
+ mi.ptszName = PopupOptions.ModuleIsEnabled ? LPGENT("Disable Popups") : LPGENT("Enable Popups");
+ mi.pszService = MENUCOMMAND_SVC;
+ hMenuItem = Menu_AddMainMenuItem(&mi);
// Popup History
CreateServiceFunction(MENUCOMMAND_HISTORY, svcShowHistory);
- mi.position = 1000000000;
- mi.popupPosition = 1999990000;
- mi.ptszName = LPGENT("Popup History");
- mi.hIcon = IcoLib_GetIcon(ICO_HISTORY, 0);
- mi.pszService = MENUCOMMAND_HISTORY;
- hMenuItemHistory = Menu_AddMainMenuItem(&mi);
-
+ mi.position = 1000000000;
+ mi.popupPosition = 1999990000;
+ mi.ptszName = LPGENT("Popup History");
+ mi.hIcon = IcoLib_GetIcon(ICO_HISTORY, 0);
+ mi.pszService = MENUCOMMAND_HISTORY;
+ hMenuItemHistory = Menu_AddMainMenuItem(&mi);
}
-//===== GetStatus =====
+//===== GetStatus =======================================================================
INT_PTR GetStatus(WPARAM, LPARAM)
{
return PopupOptions.ModuleIsEnabled;
}
-
-//register Hotkey
+// register Hotkey
void LoadHotkey()
{
HOTKEYDESC hk = { sizeof(hk) };
@@ -250,40 +238,42 @@ void LoadHotkey() Hotkey_Register(&hk);
}
-//menu
-//Function which makes the initializations
+// menu
+// Function which makes the initializations
static int ModulesLoaded(WPARAM,LPARAM)
{
- //check if History++ is installed
+ // check if History++ is installed
gbHppInstalled = ServiceExists(MS_HPP_GETVERSION) && ServiceExists(MS_HPP_EG_WINDOW) &&
(CallService(MS_HPP_GETVERSION, 0, 0) >= PLUGIN_MAKE_VERSION(1,5,0,112));
- //check if MText plugin is installed
+
+ // check if MText plugin is installed
+ mir_getMTI(&MText);
if (MText.Register) {
htuText = MText.Register("Popup Plus/Text", MTEXT_FANCY_DEFAULT);
htuTitle = MText.Register("Popup Plus/Title",MTEXT_FANCY_DEFAULT);
}
else htuTitle = htuText = NULL;
- //check if OptionLoaded
+ // check if OptionLoaded
if (!OptionLoaded)
LoadOptions();
- //Uninstalling purposes
+ // Uninstalling purposes
if (ServiceExists("PluginSweeper/Add"))
CallService("PluginSweeper/Add", (WPARAM)Translate(MODULNAME), (LPARAM)MODULNAME);
- //load fonts / create hook
+ // load fonts / create hook
InitFonts();
HookEvent(ME_FONT_RELOAD, FontsChanged);
- //load actions and notifications
+ // load actions and notifications
LoadActions();
LoadNotifications();
- //hook TopToolBar
+ // hook TopToolBar
HookEvent(ME_TTB_MODULELOADED, TTBLoaded);
- //Folder plugin support
+ // Folder plugin support
folderId = FoldersRegisterCustomPathT(LPGEN("Skins"), LPGEN("Popup Plus"), MIRANDA_PATHT _T("\\Skins\\Popup"));
- //load skin
+ // load skin
skins.load(_T("dir"));
const PopupSkin *skin;
if (skin = skins.getSkin(PopupOptions.SkinPack)) {
@@ -291,35 +281,35 @@ static int ModulesLoaded(WPARAM,LPARAM) PopupOptions.SkinPack = mir_tstrdup(skin->getName());
skin->loadOpts();
}
- //init PopupEfects
+ // init PopupEfects
PopupEfectsInitialize();
- //MessageAPI support
+ // MessageAPI support
SrmmMenu_Load();
- //Hotkey
+ // Hotkey
LoadHotkey();
gbPopupLoaded = TRUE;
return 0;
}
-//=== DllMain =====
-//DLL entry point, Required to store the instance handle
+//=== DllMain ===========================================================================
+// DLL entry point, Required to store the instance handle
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst = hinstDLL;
return TRUE;
}
-//===== MirandaPluginInfo =====
-//Called by Miranda to get the information associated to this plugin.
-//It only returns the PLUGININFOEX structure, without any test on the version
-//@param mirandaVersion - The version of the application calling this function
+//===== MirandaPluginInfo ===============================================================
+// Called by Miranda to get the information associated to this plugin.
+// It only returns the PLUGININFOEX structure, without any test on the version
+// @param mirandaVersion - The version of the application calling this function
MIRAPI PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
-//called before the app goes into shutdown routine to make sure everyone is happy to exit
+// called before the app goes into shutdown routine to make sure everyone is happy to exit
static int OkToExit(WPARAM, LPARAM)
{
closing = TRUE;
@@ -334,14 +324,13 @@ static int OnShutdown(WPARAM, LPARAM) return 0;
}
-//===== Load =====
-//Initializes the services provided and the link to those needed
-//Called when the plugin is loaded into Miranda
+//===== Load ============================================================================
+// Initializes the services provided and the link to those needed
+// Called when the plugin is loaded into Miranda
MIRAPI int Load(void)
{
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0);
- mir_getMTI(&MText);
mir_getLP(&pluginInfoEx);
CreateServiceFunction(MS_POPUP_GETSTATUS, GetStatus);
@@ -353,7 +342,7 @@ MIRAPI int Load(void) #endif
LoadGDIPlus();
- //Transparent and animation routines
+ // Transparent and animation routines
hDwmapiDll = LoadLibrary(_T("dwmapi.dll"));
MyDwmEnableBlurBehindWindow = 0;
if (hDwmapiDll)
@@ -363,7 +352,7 @@ MIRAPI int Load(void) LoadPopupThread();
if (!LoadPopupWnd2()) {
MessageBox(0, TranslateT("Error: I could not register the Popup Window class.\r\nThe plugin will not operate."), _T(MODULNAME_LONG), MB_ICONSTOP | MB_OK);
- return 0; //We couldn't register our Window Class, don't hook any event: the plugin will act as if it was disabled.
+ return 0; // We couldn't register our Window Class, don't hook any event: the plugin will act as if it was disabled.
}
RegisterOptPrevBox();
@@ -380,7 +369,7 @@ MIRAPI int Load(void) if (!OptionLoaded)
LoadOptions();
- //Service Functions
+ // Service Functions
hEventNotify = CreateHookableEvent(ME_POPUP_FILTER);
CreateServiceFunction(MS_POPUP_ADDPOPUP, Popup_AddPopup);
@@ -410,18 +399,18 @@ MIRAPI int Load(void) CreateServiceFunction(MS_POPUP_UNREGISTERCLASS, Popup_UnregisterPopupClass);
CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, Popup_CreateClassPopup);
- //load icons / create hook
+ // load icons / create hook
InitIcons();
HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
- //add menu items
+ // add menu items
InitMenuItems();
return 0;
}
-//===== Unload =====
-//Prepare the plugin to stop
-//Called by Miranda when it will exit or when the plugin gets deselected
+//===== Unload ==========================================================================
+// Prepare the plugin to stop
+// Called by Miranda when it will exit or when the plugin gets deselected
MIRAPI int Unload(void)
{
|