diff options
author | Mataes <mataes2007@gmail.com> | 2018-05-16 21:48:52 +0300 |
---|---|---|
committer | Mataes <mataes2007@gmail.com> | 2018-05-16 21:49:13 +0300 |
commit | 650fc5a2103cedfe149500ade9c684ecf381d348 (patch) | |
tree | a7f4727baa7b298992a65d240a6017dda3a82f9a /plugins/FavContacts/src | |
parent | f1195d51ea8094492fcf63a301f2cdc9d1173d6c (diff) |
FavContacts, FileAsMessage, Fingerprint, FloatingContacts, Folders, FTPFile: cmplugin adaptation
Diffstat (limited to 'plugins/FavContacts/src')
-rw-r--r-- | plugins/FavContacts/src/main.cpp | 11 | ||||
-rw-r--r-- | plugins/FavContacts/src/menu.cpp | 36 | ||||
-rw-r--r-- | plugins/FavContacts/src/options.cpp | 112 | ||||
-rw-r--r-- | plugins/FavContacts/src/stdafx.h | 10 |
4 files changed, 83 insertions, 86 deletions
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index dedc1cb097..6c023ea33a 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -22,8 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "http_api.h"
-HINSTANCE g_hInst;
-
+CMPlugin g_plugin;
int hLangpack;
PLUGININFOEX pluginInfo = {
@@ -49,12 +48,6 @@ CContactCache *g_contactCache = nullptr; Options g_Options = { 0 };
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- g_hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
@@ -74,7 +67,7 @@ extern "C" __declspec(dllexport) int Load(void) /////////////////////////////////////////////////////////////////////////////////////
- Icon_Register(g_hInst, LPGEN("Favorites"), iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), LPGEN("Favorites"), iconList, _countof(iconList));
LoadHttpApi();
return 0;
diff --git a/plugins/FavContacts/src/menu.cpp b/plugins/FavContacts/src/menu.cpp index 4e6bab443a..15da617d05 100644 --- a/plugins/FavContacts/src/menu.cpp +++ b/plugins/FavContacts/src/menu.cpp @@ -361,28 +361,28 @@ static LRESULT CALLBACK MenuHostWndProc(HWND hwnd, UINT message, WPARAM wParam, switch (message) {
case WM_MEASUREITEM:
- {
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
- if (lpmis->CtlType != ODT_MENU)
- return FALSE;
+ {
+ LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
+ if (lpmis->CtlType != ODT_MENU)
+ return FALSE;
- if ((lpmis->itemID >= CLISTMENUIDMIN) && (lpmis->itemID <= CLISTMENUIDMAX))
- return Menu_MeasureItem(lParam);
+ if ((lpmis->itemID >= CLISTMENUIDMIN) && (lpmis->itemID <= CLISTMENUIDMAX))
+ return Menu_MeasureItem(lParam);
- return MenuMeasureItem(lpmis);
- }
+ return MenuMeasureItem(lpmis);
+ }
case WM_DRAWITEM:
- {
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlType != ODT_MENU)
- return FALSE;
+ {
+ LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
+ if (lpdis->CtlType != ODT_MENU)
+ return FALSE;
- if ((lpdis->itemID >= CLISTMENUIDMIN) && (lpdis->itemID <= CLISTMENUIDMAX))
- return Menu_DrawItem(lParam);
+ if ((lpdis->itemID >= CLISTMENUIDMIN) && (lpdis->itemID <= CLISTMENUIDMAX))
+ return Menu_DrawItem(lParam);
- return MenuDrawItem(lpdis);
- }
+ return MenuDrawItem(lpdis);
+ }
case WM_MENUCHAR:
while (GetMenuItemCount((HMENU)lParam) > 1)
@@ -536,13 +536,13 @@ void InitMenu() {
WNDCLASSEX wcl = { sizeof(wcl) };
wcl.lpfnWndProc = MenuHostWndProc;
- wcl.hInstance = g_hInst;
+ wcl.hInstance = g_plugin.getInst();
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszClassName = L"FavContactsMenuHostWnd";
RegisterClassEx(&wcl);
- g_hwndMenuHost = CreateWindow(L"FavContactsMenuHostWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_hInst, nullptr);
+ g_hwndMenuHost = CreateWindow(L"FavContactsMenuHostWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
SetWindowPos(g_hwndMenuHost, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
}
diff --git a/plugins/FavContacts/src/options.cpp b/plugins/FavContacts/src/options.cpp index eac163e889..27f2946cdb 100644 --- a/plugins/FavContacts/src/options.cpp +++ b/plugins/FavContacts/src/options.cpp @@ -27,7 +27,7 @@ void LoadOptions() g_Options.bAvatarBorder = db_get_b(NULL, "FavContacts", "AvatarBorder", 0);
g_Options.wAvatarRadius = db_get_w(NULL, "FavContacts", "AvatarRadius", 3);
g_Options.bNoTransparentBorder = db_get_b(NULL, "FavContacts", "NoTransparentBorder",
- !db_get_b(NULL, "FavContacts", "AvatarBorderTransparent", 1));
+ !db_get_b(NULL, "FavContacts", "AvatarBorderTransparent", 1));
g_Options.bSysColors = db_get_b(NULL, "FavContacts", "SysColors", 0);
g_Options.bCenterHotkey = db_get_b(NULL, "FavContacts", "CenterHotkey", 1);
g_Options.bUseGroups = db_get_b(NULL, "FavContacts", "UseGroups", 0);
@@ -85,7 +85,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA SetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, g_Options.wMaxRecent, FALSE);
SetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE,
- GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
+ GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));
@@ -93,8 +93,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA {
for (auto &hContact : Contacts())
SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK,
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0),
- db_get_b(hContact, "FavContacts", "IsFavourite", 0));
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0),
+ db_get_b(hContact, "FavContacts", "IsFavourite", 0));
}
bInitialized = true;
@@ -102,59 +102,59 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA return TRUE;
case WM_APP:
- {
- BOOL bGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
- EnableWindow(GetDlgItem(hwnd, IDC_CHK_GROUPCOLUMS), bGroups);
-
- BOOL bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
- BOOL bBorders = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
- EnableWindow(GetDlgItem(hwnd, IDC_CHK_AVATARBORDER), bAvatars);
- EnableWindow(GetDlgItem(hwnd, IDC_CHK_RIGHTAVATARS), bAvatars);
- EnableWindow(GetDlgItem(hwnd, IDC_CHK_NOTRANSPARENTBORDER), bAvatars && bBorders);
- EnableWindow(GetDlgItem(hwnd, IDC_TXT_RADIUS), bAvatars && bBorders);
- }
- return TRUE;
+ {
+ BOOL bGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
+ EnableWindow(GetDlgItem(hwnd, IDC_CHK_GROUPCOLUMS), bGroups);
+
+ BOOL bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
+ BOOL bBorders = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
+ EnableWindow(GetDlgItem(hwnd, IDC_CHK_AVATARBORDER), bAvatars);
+ EnableWindow(GetDlgItem(hwnd, IDC_CHK_RIGHTAVATARS), bAvatars);
+ EnableWindow(GetDlgItem(hwnd, IDC_CHK_NOTRANSPARENTBORDER), bAvatars && bBorders);
+ EnableWindow(GetDlgItem(hwnd, IDC_TXT_RADIUS), bAvatars && bBorders);
+ }
+ return TRUE;
case WM_DRAWITEM:
- {
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlID == IDC_CANVAS) {
- MEASUREITEMSTRUCT mis = { 0 };
- DRAWITEMSTRUCT dis = *lpdis;
-
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_BTNFACE));
- if (hSelectedContact) {
- Options options;
- options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
- options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
- options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
- options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER);
- options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS);
- options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
- options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
- options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
- options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, nullptr, FALSE);
- options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, nullptr, FALSE);
-
- mis.CtlID = 0;
- mis.CtlType = ODT_MENU;
- mis.itemData = (DWORD)hSelectedContact;
- MenuMeasureItem(&mis, &options);
- dis.rcItem.bottom = dis.rcItem.top + mis.itemHeight;
-
- dis.CtlID = 0;
- dis.CtlType = ODT_MENU;
- dis.itemData = (DWORD)hSelectedContact;
- MenuDrawItem(&dis, &options);
-
- RECT rc = lpdis->rcItem;
- rc.bottom = rc.top + mis.itemHeight;
- FrameRect(lpdis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
- }
- return TRUE;
+ {
+ LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
+ if (lpdis->CtlID == IDC_CANVAS) {
+ MEASUREITEMSTRUCT mis = { 0 };
+ DRAWITEMSTRUCT dis = *lpdis;
+
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_BTNFACE));
+ if (hSelectedContact) {
+ Options options;
+ options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
+ options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
+ options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
+ options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER);
+ options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS);
+ options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
+ options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
+ options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
+ options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, nullptr, FALSE);
+ options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, nullptr, FALSE);
+
+ mis.CtlID = 0;
+ mis.CtlType = ODT_MENU;
+ mis.itemData = (DWORD)hSelectedContact;
+ MenuMeasureItem(&mis, &options);
+ dis.rcItem.bottom = dis.rcItem.top + mis.itemHeight;
+
+ dis.CtlID = 0;
+ dis.CtlType = ODT_MENU;
+ dis.itemData = (DWORD)hSelectedContact;
+ MenuDrawItem(&dis, &options);
+
+ RECT rc = lpdis->rcItem;
+ rc.bottom = rc.top + mis.itemHeight;
+ FrameRect(lpdis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
}
+ return TRUE;
}
- return FALSE;
+ }
+ return FALSE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
@@ -209,7 +209,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA for (auto &hContact : Contacts()) {
BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK,
- SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0);
+ SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0);
if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0))
db_set_b(hContact, "FavContacts", "IsFavourite", fav);
if (fav) CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
@@ -228,7 +228,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA for (auto &hContact : Contacts()) {
if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) {
SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection,
- db_get_b(hContact, "FavContacts", "IsFavourite", 0));
+ db_get_b(hContact, "FavContacts", "IsFavourite", 0));
break;
}
}
@@ -255,7 +255,7 @@ int ProcessOptInitialise(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = g_hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szGroup.a = LPGEN("Contacts");
odp.szTitle.a = LPGEN("Favorites");
diff --git a/plugins/FavContacts/src/stdafx.h b/plugins/FavContacts/src/stdafx.h index 17b0d3ca6b..7de5e1728d 100644 --- a/plugins/FavContacts/src/stdafx.h +++ b/plugins/FavContacts/src/stdafx.h @@ -29,8 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <time.h>
#include <math.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <win2k.h>
#include <newpluginapi.h>
#include <m_system.h>
@@ -101,5 +99,11 @@ void UninitMenu(); void InitServices();
void UninitServices();
-extern HINSTANCE g_hInst;
extern IconItem iconList[];
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>("FavContacts")
+ {}
+};
|