From 650fc5a2103cedfe149500ade9c684ecf381d348 Mon Sep 17 00:00:00 2001 From: Mataes Date: Wed, 16 May 2018 21:48:52 +0300 Subject: FavContacts, FileAsMessage, Fingerprint, FloatingContacts, Folders, FTPFile: cmplugin adaptation --- plugins/FloatingContacts/src/fltcont.h | 22 +++++++--------- plugins/FloatingContacts/src/main.cpp | 43 +++++++++++++------------------- plugins/FloatingContacts/src/options.cpp | 40 ++++++++++++++--------------- plugins/FloatingContacts/src/stdafx.h | 11 ++++++-- 4 files changed, 55 insertions(+), 61 deletions(-) (limited to 'plugins/FloatingContacts/src') diff --git a/plugins/FloatingContacts/src/fltcont.h b/plugins/FloatingContacts/src/fltcont.h index ca4919c2fc..81afdedce5 100644 --- a/plugins/FloatingContacts/src/fltcont.h +++ b/plugins/FloatingContacts/src/fltcont.h @@ -11,15 +11,15 @@ #define WM_REFRESH_CONTACT WM_USER + 0x100 #ifndef WS_EX_LAYERED - #define WS_EX_LAYERED 0x00080000 +#define WS_EX_LAYERED 0x00080000 #endif #ifndef LWA_ALPHA - #define LWA_ALPHA 0x00000002 +#define LWA_ALPHA 0x00000002 #endif #ifndef ULW_ALPHA - #define ULW_ALPHA 0x00000002 +#define ULW_ALPHA 0x00000002 #endif #define TIMERID_SELECT_T 1 @@ -57,8 +57,6 @@ enum ///////////////////////////////////////////////////////////////////////////// // -#define MODULE "FloatingContacts" - #define TOTOPTIME_P 1000 #define TOTOPTIME_MAX (15*(60000/TOTOPTIME_P)) #define TOTOPTIME_DEF (3*(60000/TOTOPTIME_P)) @@ -68,8 +66,6 @@ enum #define DB_POS_GETY(pos) (short)(((float)(short)(HIWORD(pos))*(float)GetSystemMetrics(SM_CYSCREEN))/MAXRCOOR+0.5) #define DB_POS_MAKE_XY(x, y) MAKELONG((short)(((float)x*MAXRCOOR)/(float)GetSystemMetrics(SM_CXSCREEN)+0.5), (short)(((float)y*MAXRCOOR)/(float)GetSystemMetrics(SM_CYSCREEN)+0.5)) -extern HINSTANCE hInst; - //extern BOOL bHideOffline; //extern BOOL bHideAll; //extern BOOL bHideWhenFullscreen; @@ -117,7 +113,7 @@ typedef struct _FCOptions BOOL bHideWhenCListShow; BOOL bUseSingleClick; BOOL bShowIdle; -} +} FCOptions; extern FCOptions fcOpt; @@ -132,11 +128,11 @@ static __forceinline BOOL ImageList_GetIconSize_my(HIMAGELIST himl, SIZE &sz) return res; } -void RegHotkey ( MCONTACT hContact, HWND hwnd ); -BOOL IsStatusVisible ( int status ); -BOOL HideOnFullScreen (); -void SendMsgDialog ( HWND hwnd, wchar_t *pText ); -void SaveContactsPos ( void ); +void RegHotkey(MCONTACT hContact, HWND hwnd); +BOOL IsStatusVisible(int status); +BOOL HideOnFullScreen(); +void SendMsgDialog(HWND hwnd, wchar_t *pText); +void SaveContactsPos(void); ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/FloatingContacts/src/main.cpp b/plugins/FloatingContacts/src/main.cpp index 94c00f420b..28d6b872b3 100644 --- a/plugins/FloatingContacts/src/main.cpp +++ b/plugins/FloatingContacts/src/main.cpp @@ -38,7 +38,6 @@ static int ClcStatusToPf2(int status); static VOID CALLBACK ToTopTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); -HINSTANCE hInst; HFONT hFont[FLT_FONTIDS]; COLORREF tColor[FLT_FONTIDS]; HIMAGELIST himlMiranda; @@ -63,6 +62,7 @@ BOOL bIsCListShow; HGENMENU hMenuItemRemove, hMenuItemHideAll, hMainMenuItemHideAll; +CMPlugin g_plugin; int hLangpack; CLIST_INTERFACE *pcli; @@ -107,15 +107,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfoEx; } -/////////////////////////////////////////////////////// -// Load / unload - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} - ///////////////////////////////////////////////////////////////////////////// // Fonts @@ -334,17 +325,17 @@ static LRESULT __stdcall CommWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM switch (uMsg) { case WM_RBUTTONUP: - { - POINT pt; - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); + { + POINT pt; + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); - if (pThumb) pThumb->ThumbDeselect(TRUE); + if (pThumb) pThumb->ThumbDeselect(TRUE); - ClientToScreen(hwnd, &pt); - ShowContactMenu(hwnd, pt); - } - break; + ClientToScreen(hwnd, &pt); + ShowContactMenu(hwnd, pt); + } + break; case WM_CLOSE: DestroyWindow(hwnd); @@ -487,7 +478,7 @@ static void RegisterWindowClass() wcx.cbSize = sizeof(WNDCLASSEX); wcx.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; wcx.lpfnWndProc = CommWndProc; - wcx.hInstance = hInst; + wcx.hInstance = g_plugin.getInst(); wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wcx.lpszClassName = WND_CLASS; RegisterClassEx(&wcx); @@ -495,7 +486,7 @@ static void RegisterWindowClass() static void UnregisterWindowClass() { - UnregisterClass(WND_CLASS, hInst); + UnregisterClass(WND_CLASS, g_plugin.getInst()); } static void CreateThumbWnd(wchar_t *ptszName, MCONTACT hContact, int nX, int nY) @@ -505,7 +496,7 @@ static void CreateThumbWnd(wchar_t *ptszName, MCONTACT hContact, int nX, int nY) return; // Prepare for window creation - HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, WND_CLASS, ptszName, WS_POPUP, nX, nY, 50, 20, nullptr, nullptr, hInst, nullptr); + HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, WND_CLASS, ptszName, WS_POPUP, nX, nY, 50, 20, nullptr, nullptr, g_plugin.getInst(), nullptr); if (hwnd == nullptr) return; @@ -719,10 +710,10 @@ static void LoadMenus() // Remove thumb menu item CreateServiceFunction(MODULE "/RemoveThumb", OnContactMenu_Remove); - SET_UID(mi,0xbab83df0, 0xe126, 0x4d9a, 0xbc, 0xc3, 0x2b, 0xea, 0x84, 0x90, 0x58, 0xc8); + SET_UID(mi, 0xbab83df0, 0xe126, 0x4d9a, 0xbc, 0xc3, 0x2b, 0xea, 0x84, 0x90, 0x58, 0xc8); mi.position = 0xFFFFF; mi.flags = CMIF_UNICODE; - mi.hIcolibItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_HIDE)); + mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_HIDE)); mi.name.w = LPGENW("Remove thumb"); mi.pszService = MODULE "/RemoveThumb"; hMenuItemRemove = Menu_AddContactMenuItem(&mi); @@ -843,7 +834,7 @@ static LRESULT __stdcall newMirandaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, if (method) { WORD wBehindEdgeBorderSize = db_get_w(NULL, "ModernData", "HideBehindBorderSize", 0); RECT rc = { wp->x, wp->y, wp->x + wp->cx, wp->y + wp->cy }; - RECT rcScr = { wBehindEdgeBorderSize*(2 - method), 0, GetSystemMetrics(SM_CXSCREEN) - wBehindEdgeBorderSize*(method - 1), GetSystemMetrics(SM_CYSCREEN) }; + RECT rcScr = { wBehindEdgeBorderSize*(2 - method), 0, GetSystemMetrics(SM_CXSCREEN) - wBehindEdgeBorderSize * (method - 1), GetSystemMetrics(SM_CYSCREEN) }; RECT rcOverlap; BOOL isIntersect = IntersectRect(&rcOverlap, &rc, &rcScr); if (!isIntersect && bIsCListShow) { @@ -914,7 +905,7 @@ extern "C" int __declspec(dllexport) Load() mir_getLP(&pluginInfoEx); pcli = Clist_GetInterface(); - Icon_RegisterT(hInst, _A2W(MODULE), g_iconList, _countof(g_iconList)); + Icon_RegisterT(g_plugin.getInst(), _A2W(MODULE), g_iconList, _countof(g_iconList)); LoadMenus(); InitOptions(); diff --git a/plugins/FloatingContacts/src/options.cpp b/plugins/FloatingContacts/src/options.cpp index c27c29b242..f34b610674 100644 --- a/plugins/FloatingContacts/src/options.cpp +++ b/plugins/FloatingContacts/src/options.cpp @@ -243,25 +243,25 @@ static INT_PTR APIENTRY OptSknWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP break; case IDC_BROWSE: - { - wchar_t str[MAX_PATH], filter[512]; - GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str)); - Bitmap_GetFilter(filter, _countof(filter)); - - OPENFILENAME ofn = { 0 }; - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwndDlg; - ofn.lpstrFilter = filter; - ofn.lpstrFile = str; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - ofn.nMaxFile = _countof(str); - ofn.nMaxFileTitle = MAX_PATH; - ofn.lpstrDefExt = L"bmp"; - if (!GetOpenFileName(&ofn)) - return FALSE; - SetDlgItemText(hwndDlg, IDC_FILENAME, str); - } - break; + { + wchar_t str[MAX_PATH], filter[512]; + GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str)); + Bitmap_GetFilter(filter, _countof(filter)); + + OPENFILENAME ofn = { 0 }; + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwndDlg; + ofn.lpstrFilter = filter; + ofn.lpstrFile = str; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + ofn.nMaxFile = _countof(str); + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = L"bmp"; + if (!GetOpenFileName(&ofn)) + return FALSE; + SetDlgItemText(hwndDlg, IDC_FILENAME, str); + } + break; case IDC_FILENAME: if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus()) @@ -333,7 +333,7 @@ static INT_PTR APIENTRY OptSknWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP int OnOptionsInitialize(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_plugin.getInst(); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FLTCONT); odp.szTitle.a = LPGEN("Floating Contacts"); odp.szGroup.a = LPGEN("Contact list"); diff --git a/plugins/FloatingContacts/src/stdafx.h b/plugins/FloatingContacts/src/stdafx.h index 6eb9a4eaf1..82a8666bb7 100644 --- a/plugins/FloatingContacts/src/stdafx.h +++ b/plugins/FloatingContacts/src/stdafx.h @@ -8,8 +8,6 @@ #include #include -#define __NO_CMPLUGIN_NEEDED - #include #include #include @@ -34,6 +32,15 @@ ///////////////////////////////////////////////////////////////////////////// +#define MODULE "FloatingContacts" + +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(MODULE) + {} +}; + #endif // #ifndef __STDHDR_H__ ///////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3