From 2e8582832fe56c89bb422b82e884ddaf67a8dbb3 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 16 May 2018 13:28:43 +0300 Subject: AutoShutdown: cmplugin adaptation --- plugins/AutoShutdown/src/frame.cpp | 7 +++---- plugins/AutoShutdown/src/main.cpp | 10 ++-------- plugins/AutoShutdown/src/options.cpp | 3 +-- plugins/AutoShutdown/src/settingsdlg.cpp | 3 +-- plugins/AutoShutdown/src/shutdownsvc.cpp | 3 +-- plugins/AutoShutdown/src/stdafx.h | 9 +++++++-- 6 files changed, 15 insertions(+), 20 deletions(-) (limited to 'plugins/AutoShutdown/src') diff --git a/plugins/AutoShutdown/src/frame.cpp b/plugins/AutoShutdown/src/frame.cpp index 89b010b0b7..c8a279189b 100644 --- a/plugins/AutoShutdown/src/frame.cpp +++ b/plugins/AutoShutdown/src/frame.cpp @@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" /* Show Frame */ -extern HINSTANCE hInst; static HWND hwndCountdownFrame; static WORD hFrame; /* Misc */ @@ -490,7 +489,7 @@ void ShowCountdownFrame(WORD fTimeFlags) GetSystemMetrics(SM_CYICON) + 2, pcli->hwndContactList, nullptr, - hInst, + g_plugin.getInst(), &fTimeFlags); if (hwndCountdownFrame == nullptr) return; @@ -572,7 +571,7 @@ int InitFrame(void) wcx.cbSize = sizeof(wcx); wcx.style = CS_DBLCLKS | CS_PARENTDC; wcx.lpfnWndProc = FrameWndProc; - wcx.hInstance = hInst; + wcx.hInstance = g_plugin.getInst(); wcx.hCursor = (HCURSOR)LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED); wcx.lpszClassName = COUNTDOWNFRAME_CLASS; if (!RegisterClassEx(&wcx)) @@ -586,6 +585,6 @@ int InitFrame(void) void UninitFrame(void) { /* frame closed by UninitWatcher() */ - UnregisterClass(COUNTDOWNFRAME_CLASS, hInst); /* fails if window still exists */ + UnregisterClass(COUNTDOWNFRAME_CLASS, g_plugin.getInst()); /* fails if window still exists */ UnhookEvent(hHookModulesLoaded); } diff --git a/plugins/AutoShutdown/src/main.cpp b/plugins/AutoShutdown/src/main.cpp index 8f7b49e539..d25e969f60 100644 --- a/plugins/AutoShutdown/src/main.cpp +++ b/plugins/AutoShutdown/src/main.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" CLIST_INTERFACE *pcli; -HINSTANCE hInst; +CMPlugin g_plugin; int hLangpack; PLUGININFOEX pluginInfo = { @@ -44,12 +44,6 @@ IconItem iconList[] = { LPGEN("Inactive"), "AutoShutdown_Inactive", IDI_INACTIVE }, }; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, VOID*) -{ - hInst = hinstDLL; - return TRUE; -} - static int ShutdownModulesLoaded(WPARAM, LPARAM) { /* Toolbar Item */ @@ -77,7 +71,7 @@ extern "C" __declspec(dllexport) int Load(void) if (InitFrame()) return 1; /* before icons */ /* shared */ - Icon_Register(hInst, "Automatic Shutdown", iconList, _countof(iconList)); + Icon_Register(g_plugin.getInst(), "Automatic Shutdown", iconList, _countof(iconList)); InitShutdownSvc(); InitWatcher(); /* before InitSettingsDlg() */ diff --git a/plugins/AutoShutdown/src/options.cpp b/plugins/AutoShutdown/src/options.cpp index c9b8a508ce..f0b2255566 100644 --- a/plugins/AutoShutdown/src/options.cpp +++ b/plugins/AutoShutdown/src/options.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Option Page */ static HANDLE hHookOptInit; -extern HINSTANCE hInst; /* Trigger */ static HANDLE hHookModulesLoaded; @@ -107,7 +106,7 @@ static INT_PTR CALLBACK ShutdownOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam static int ShutdownOptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_plugin.getInst(); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SHUTDOWN); odp.position = 900000002; odp.szGroup.w = LPGENW("Events"); /* autotranslated */ diff --git a/plugins/AutoShutdown/src/settingsdlg.cpp b/plugins/AutoShutdown/src/settingsdlg.cpp index 1aca711b4b..2e7b6003ec 100644 --- a/plugins/AutoShutdown/src/settingsdlg.cpp +++ b/plugins/AutoShutdown/src/settingsdlg.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Services */ static HWND hwndSettingsDlg; -extern HINSTANCE hInst; const DWORD unitValues[] = { 1,60,60 * 60,60 * 60 * 24,60 * 60 * 24 * 7,60 * 60 * 24 * 31 }; const wchar_t *unitNames[] = { LPGENW("Second(s)"), LPGENW("Minute(s)"), LPGENW("Hour(s)"), LPGENW("Day(s)"), LPGENW("Week(s)"), LPGENW("Month(s)") }; @@ -400,7 +399,7 @@ static INT_PTR ServiceShowSettingsDialog(WPARAM, LPARAM) SetForegroundWindow(hwndSettingsDlg); return 0; } - return CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETTINGS), nullptr, SettingsDlgProc) == nullptr; + return CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETTINGS), nullptr, SettingsDlgProc) == nullptr; } /************************* Toolbar ************************************/ diff --git a/plugins/AutoShutdown/src/shutdownsvc.cpp b/plugins/AutoShutdown/src/shutdownsvc.cpp index bce97d110c..377da09040 100644 --- a/plugins/AutoShutdown/src/shutdownsvc.cpp +++ b/plugins/AutoShutdown/src/shutdownsvc.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Shutdown Dialog */ static HWND hwndShutdownDlg; -extern HINSTANCE hInst; /* Events */ static HANDLE hEventOkToShutdown,hEventShutdown; @@ -430,7 +429,7 @@ INT_PTR ServiceShutdown(WPARAM wParam, LPARAM lParam) NotifyEventHooks(hEventShutdown, wParam, lParam); /* show dialog */ if (lParam && db_get_b(NULL, "AutoShutdown", "ShowConfirmDlg", SETTING_SHOWCONFIRMDLG_DEFAULT)) - if (CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SHUTDOWNNOW), nullptr, ShutdownDlgProc, (BYTE)wParam) != nullptr) + if (CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SHUTDOWNNOW), nullptr, ShutdownDlgProc, (BYTE)wParam) != nullptr) return 0; /* show error */ diff --git a/plugins/AutoShutdown/src/stdafx.h b/plugins/AutoShutdown/src/stdafx.h index 7a22b307d6..c0b60f6181 100644 --- a/plugins/AutoShutdown/src/stdafx.h +++ b/plugins/AutoShutdown/src/stdafx.h @@ -42,8 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include /* for RasEnumConnections(), RasHangUp() */ #include /* error codes for RAS */ -#define __NO_CMPLUGIN_NEEDED - #include #include #include @@ -76,4 +74,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "resource.h" #include "version.h" +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN("AutoShutdown") + {} +}; + extern IconItem iconList[]; \ No newline at end of file -- cgit v1.2.3