From 91bf98433bfabfb2274511525b5be97d8e8d27f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 16 May 2018 20:48:02 +0300 Subject: Scriver -> CMPlugin --- plugins/Scriver/src/chat_window.cpp | 2 +- plugins/Scriver/src/globals.cpp | 8 ++++---- plugins/Scriver/src/infobar.cpp | 2 +- plugins/Scriver/src/input.cpp | 2 +- plugins/Scriver/src/msgdialog.cpp | 4 ++-- plugins/Scriver/src/msgoptions.cpp | 6 +++--- plugins/Scriver/src/msgs.cpp | 4 ++-- plugins/Scriver/src/msgtimedout.cpp | 2 +- plugins/Scriver/src/srmm.cpp | 16 +++++++++------- plugins/Scriver/src/stdafx.h | 8 +++++++- plugins/Scriver/src/tabs.cpp | 6 +++--- plugins/Scriver/src/utils.cpp | 8 ++++---- 12 files changed, 38 insertions(+), 30 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index ad31b1805e..1e15a44cb4 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -424,7 +424,7 @@ void CChatRoomDlg::ScrollToBottom() void CChatRoomDlg::ShowFilterMenu() { - HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this); + HWND hwnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this); TranslateDialogDefault(hwnd); RECT rc; diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index d63e8f29ec..e826a70f63 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -96,9 +96,9 @@ void RegisterIcons(void) { HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged); - Icon_Register(g_hInst, LPGEN("Single Messaging"), iconList, 14); - Icon_Register(g_hInst, LPGEN("Group chats"), iconList+14, 20); - Icon_Register(g_hInst, LPGEN("Single Messaging"), iconList+34, 14); + Icon_Register(g_plugin.getInst(), LPGEN("Single Messaging"), iconList, 14); + Icon_Register(g_plugin.getInst(), LPGEN("Group chats"), iconList+14, 20); + Icon_Register(g_plugin.getInst(), LPGEN("Single Messaging"), iconList+34, 14); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -241,7 +241,7 @@ void LoadGlobalIcons() int overlayIcon = ImageList_AddIcon(g_dat.hHelperIconList, GetCachedIcon("scriver_OVERLAY")); ImageList_SetOverlayImage(g_dat.hHelperIconList, overlayIcon, 1); for (int i = IDI_GOOGLE; i < IDI_LASTICON; i++) { - HICON hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(i), IMAGE_ICON, 0, 0, 0); + HICON hIcon = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(i), IMAGE_ICON, 0, 0, 0); ImageList_AddIcon(g_dat.hSearchEngineIconList, hIcon); DestroyIcon(hIcon); } diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp index 1bb6d077c0..2bdfe366d6 100644 --- a/plugins/Scriver/src/infobar.cpp +++ b/plugins/Scriver/src/infobar.cpp @@ -265,6 +265,6 @@ static INT_PTR CALLBACK InfobarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA void CSrmmWindow::CreateInfobar() { - m_hwndInfo = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_INFOBAR), m_hwnd, InfobarWndProc, (LPARAM)this); + m_hwndInfo = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_INFOBAR), m_hwnd, InfobarWndProc, (LPARAM)this); SetWindowPos(m_hwndInfo, HWND_TOP, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOREPOSITION); } diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index c5034ea3eb..2302c01c7d 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -32,7 +32,7 @@ void InputAreaContextMenu(HWND hwnd, WPARAM, LPARAM lParam, MCONTACT hContact) POINT pt; CHARRANGE sel, all = { 0, -1 }; - HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT)); HMENU hSubMenu = GetSubMenu(hMenu, 2); TranslateMenu(hSubMenu); SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8bc0ff50cc..dfe96a95af 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -916,7 +916,7 @@ LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) return DrawMenuItem(wParam, lParam); case WM_CONTEXTMENU: - HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT)); HMENU hSubMenu = GetSubMenu(hMenu, 0); TranslateMenu(hSubMenu); @@ -1611,7 +1611,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case IDC_SENDALL: int result; if (m_iSendAllConfirm == 0) { - result = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CONFIRM_SENDALL), m_hwnd, ConfirmSendAllDlgProc, (LPARAM)m_hwnd); + result = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONFIRM_SENDALL), m_hwnd, ConfirmSendAllDlgProc, (LPARAM)m_hwnd); if (result & 0x10000) m_iSendAllConfirm = result; } diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index e8876170e3..d2e4f6806a 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -622,7 +622,7 @@ class CLogOptionsDlg : public CDlgBase public: CLogOptionsDlg() : - CDlgBase(g_hInst, IDD_OPT_MSGLOG), + CDlgBase(g_plugin.getInst(), IDD_OPT_MSGLOG), m_log(this, IDC_SRMM_LOG) {} @@ -959,7 +959,7 @@ int OptInitialise(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.position = 910000000; - odp.hInstance = g_hInst; + odp.hInstance = g_plugin.getInst(); odp.szTitle.a = LPGEN("Message sessions"); odp.flags = ODPF_BOLDGROUPS; @@ -1005,7 +1005,7 @@ int OptInitialise(WPARAM wParam, LPARAM) if (g_dat.popupInstalled) { odp.position = 910000002; - odp.hInstance = g_hInst; + odp.hInstance = g_plugin.getInst(); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONSPOPUP); odp.szTitle.a = LPGEN("Messaging"); odp.szGroup.a = LPGEN("Popups"); diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 3d6279ab5a..a1f94fc2a6 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -326,7 +326,7 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam) // CScriverWindow CScriverWindow::CScriverWindow(int iDialog, SESSION_INFO *si) - : CSrmmBaseDialog(g_hInst, iDialog, si) + : CSrmmBaseDialog(g_plugin.getInst(), iDialog, si) { m_autoClose = CLOSE_ON_CANCEL; } @@ -654,7 +654,7 @@ int OnLoadModule(void) Skin_AddSound("TNStart", LPGENW("Instant messages"), LPGENW("Contact started typing")); Skin_AddSound("TNStop", LPGENW("Instant messages"), LPGENW("Contact stopped typing")); - hDragCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DRAGCURSOR)); + hDragCursor = LoadCursor(g_plugin.getInst(), MAKEINTRESOURCE(IDC_DRAGCURSOR)); Chat_Load(); return 0; diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp index 4fe279e9af..1c2a5663db 100644 --- a/plugins/Scriver/src/msgtimedout.cpp +++ b/plugins/Scriver/src/msgtimedout.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" CErrorDlg::CErrorDlg(const wchar_t *pwszDescr, HWND hWnd, MessageSendQueueItem *pItem) - : CDlgBase(g_hInst, IDD_MSGSENDERROR), + : CDlgBase(g_plugin.getInst(), IDD_MSGSENDERROR), m_wszText(mir_utf8decodeW(pItem->sendBuffer)), m_wszDescr(pwszDescr != nullptr ? pwszDescr : TranslateT("An unknown error has occurred.")), m_hwndParent(hWnd), diff --git a/plugins/Scriver/src/srmm.cpp b/plugins/Scriver/src/srmm.cpp index 493e698e23..26b671eda3 100644 --- a/plugins/Scriver/src/srmm.cpp +++ b/plugins/Scriver/src/srmm.cpp @@ -27,11 +27,13 @@ int OnLoadModule(void); int OnUnloadModule(void); int hLangpack; -HINSTANCE g_hInst; +CMPlugin g_plugin; CLIST_INTERFACE *pcli; ITaskbarList3 *pTaskbarInterface; +///////////////////////////////////////////////////////////////////////////////////////// + PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -45,19 +47,17 @@ PLUGININFOEX pluginInfo = { { 0x84636f78, 0x2057, 0x4302, { 0x8a, 0x65, 0x23, 0xa1, 0x6d, 0x46, 0x84, 0x4c } } }; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - g_hInst = hinstDLL; - return TRUE; -} - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRMM, MIID_LAST }; +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) int Load(void) { // set the memory manager @@ -70,6 +70,8 @@ extern "C" __declspec(dllexport) int Load(void) return OnLoadModule(); } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) int Unload(void) { if (pTaskbarInterface) diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 6a4765256a..a41e36b9de 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -88,7 +88,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CFM_WEIGHT 0x00400000 #endif -extern HINSTANCE g_hInst; extern HCURSOR hDragCursor; extern ITaskbarList3 *pTaskbarInterface; @@ -118,6 +117,13 @@ int StatusIconPressed(WPARAM wParam, LPARAM lParam); #include "statusicon.h" #include "chat.h" +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(SRMM_MODULE) + {} +}; + extern GlobalMessageData g_dat; #endif diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp index 8792f09ec7..2540f1d76b 100644 --- a/plugins/Scriver/src/tabs.cpp +++ b/plugins/Scriver/src/tabs.cpp @@ -638,7 +638,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara dat->iSplitterX = db_get_dw(0, SRMM_MODULE, "splitterx", -1); dat->iSplitterY = db_get_dw(0, SRMM_MODULE, "splittery", -1); dat->flags2 = g_dat.flags2; - dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, nullptr, g_hInst, nullptr); + dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, nullptr, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, nullptr, g_plugin.getInst(), nullptr); dat->isChat = newData->isChat; SendMessage(dat->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); SetupStatusBar(dat); @@ -820,7 +820,7 @@ static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wPara int tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo); if (tabId != -1) { CScriverWindow *pDlg = GetChildFromTab(dat->hwndTabs, tabId); - HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT)); HMENU hSubMenu = GetSubMenu(hMenu, 3); TranslateMenu(hSubMenu); HMENU hUserMenu = (HMENU)SendMessage(pDlg->GetHwnd(), DM_GETCONTEXTMENU, 0, 0); @@ -1417,5 +1417,5 @@ HWND GetParentWindow(MCONTACT hContact, BOOL bChat) if (!(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) newData.isChat = FALSE; - return CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), nullptr, DlgProcParentWindow, (LPARAM)&newData); + return CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MSGWIN), nullptr, DlgProcParentWindow, (LPARAM)&newData); } diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index b1585f00b5..2f304c321f 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -293,13 +293,13 @@ HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle, RECT *rec WS_POPUP | TTS_NOPREFIX, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hwndParent, nullptr, g_hInst, nullptr); + hwndParent, nullptr, g_plugin.getInst(), nullptr); SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP; ti.hwnd = hwndParent; - ti.hinst = g_hInst; + ti.hinst = g_plugin.getInst(); ti.lpszText = ptszText; ti.rect = *rect; SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM)&ti); @@ -310,7 +310,7 @@ HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle, RECT *rec void SetToolTipText(HWND hwndParent, HWND hwndTT, LPTSTR ptszText, LPTSTR ptszTitle) { TOOLINFO ti = { sizeof(ti) }; - ti.hinst = g_hInst; + ti.hinst = g_plugin.getInst(); ti.hwnd = hwndParent; ti.lpszText = ptszText; SendMessage(hwndTT, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); @@ -320,7 +320,7 @@ void SetToolTipText(HWND hwndParent, HWND hwndTT, LPTSTR ptszText, LPTSTR ptszTi void SetToolTipRect(HWND hwndParent, HWND hwndTT, RECT *rect) { TOOLINFO ti = { sizeof(ti) }; - ti.hinst = g_hInst; + ti.hinst = g_plugin.getInst(); ti.hwnd = hwndParent; ti.rect = *rect; SendMessage(hwndTT, TTM_NEWTOOLRECT, 0, (LPARAM)&ti); -- cgit v1.2.3