From 4f4b39e3e0c9b1906af739cf85311e7ca0388fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 18 Nov 2014 20:07:43 +0000 Subject: =?UTF-8?q?RecentContacts:=20Add=20option=20"Resize=20window=20acc?= =?UTF-8?q?ording=20to=20contact=20list"=20(patch=20by=20Vojt=C4=9Bch=20Ki?= =?UTF-8?q?nkor,=20thanks);=20version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@11017 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/RecentContacts/res/resource.rc | 9 ++--- plugins/RecentContacts/src/RecentContacts.cpp | 51 +++++++++++++++++++++++---- plugins/RecentContacts/src/RecentContacts.h | 3 ++ plugins/RecentContacts/src/Version.h | 2 +- plugins/RecentContacts/src/options.cpp | 20 ++++++----- plugins/RecentContacts/src/resource.h | 1 + 6 files changed, 66 insertions(+), 20 deletions(-) (limited to 'plugins/RecentContacts') diff --git a/plugins/RecentContacts/res/resource.rc b/plugins/RecentContacts/res/resource.rc index ce611070c2..a524764f45 100644 --- a/plugins/RecentContacts/res/resource.rc +++ b/plugins/RecentContacts/res/resource.rc @@ -33,18 +33,19 @@ BEGIN CONTROL "",IDC_CONTACTS_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,0,0,150,200 END -IDD_LASTUC_OPT DIALOGEX 0, 0, 314, 106 +IDD_LASTUC_OPT DIALOGEX 0, 0, 314, 122 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - GROUPBOX "Plugin settings",IDC_STATIC,7,7,300,88 + GROUPBOX "Plugin settings",IDC_STATIC,7,7,300,108 EDITTEXT IDC_SHOWNCONTACTS,161,27,28,12,ES_AUTOHSCROLL CONTROL "Number of shown contacts:\n (0 to show all)",IDC_STATIC, "Static",SS_LEFTNOWORDWRAP | WS_GROUP,15,27,141,17 - LTEXT "Format of date and time\n(Look to readme for placeholders help)",IDC_STATIC,15,50,141,22 + LTEXT "Format of date and time\n(Look to readme for placeholders help)",IDC_STATIC,15,50,141,28 EDITTEXT IDC_DATETIME,161,50,137,12,ES_AUTOHSCROLL CONTROL "Hide offline contacts",IDC_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,75,137,8 + CONTROL "Resize window according to contact list",IDC_WINDOWAUTOSIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,91,137,8 END @@ -100,7 +101,7 @@ BEGIN VERTGUIDE, 161 VERTGUIDE, 298 TOPMARGIN, 7 - BOTTOMMARGIN, 99 + BOTTOMMARGIN, 115 END END #endif // APSTUDIO_INVOKED diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index a90c9da616..5b9b26005b 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -10,7 +10,7 @@ char *szProto; HINSTANCE hInst = NULL; int hLangpack = 0; - +CLIST_INTERFACE *pcli; HANDLE hTopToolbarButtonShowList; HANDLE hMsgWndEvent; HANDLE hWindowList; @@ -61,6 +61,7 @@ void LoadDBSettings() ZeroMemory(&LastUCOpt, sizeof(LastUCOpt)); LastUCOpt.MaxShownContacts = (INT)db_get_b( NULL, dbLastUC_ModuleName, dbLastUC_MaxShownContacts, 0 ); LastUCOpt.HideOffline = db_get_b( NULL, dbLastUC_ModuleName, dbLastUC_HideOfflineContacts, 0 ); + LastUCOpt.WindowAutoSize = db_get_b( NULL, dbLastUC_ModuleName, dbLastUC_WindowAutosize, 0 ); DBVARIANT dbv; dbv.type = DBVT_ASCIIZ; @@ -264,12 +265,47 @@ INT_PTR CALLBACK ShowListMainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM break; } - SAVEWINDOWPOS pos; - pos.hContact = NULL; - pos.hwnd = hDlg; - pos.szModule = dbLastUC_ModuleName; - pos.szNamePrefix = dbLastUC_WindowPosPrefix; - CallService(MS_UTILS_RESTOREWINDOWPOSITION, 0, (LPARAM)(SAVEWINDOWPOS*)&pos); + + // window autosize/autopos - ike blaster + bool restorePos = !LastUCOpt.WindowAutoSize; + + if (!restorePos) { + RECT rect; + if (GetWindowRect(pcli->hwndContactList, &rect)) { + WINDOWPLACEMENT wp; + + wp.length = sizeof(wp); + GetWindowPlacement(hDlg, &wp); + + char szSettingName[64]; + mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", dbLastUC_WindowPosPrefix); + int width = db_get_dw(NULL, dbLastUC_ModuleName, szSettingName, -1); + + int right = rect.left - 6; + if(!IsWindowVisible(pcli->hwndContactList)) right = rect.right; + + wp.rcNormalPosition.left = right - width; + wp.rcNormalPosition.top = rect.top; + wp.rcNormalPosition.right = right; + wp.rcNormalPosition.bottom = rect.bottom; + wp.flags = 0; + + SetWindowPlacement(hDlg, &wp); + } else { + restorePos = true; + } + } + + if (restorePos) { + SAVEWINDOWPOS pos; + pos.hContact = NULL; + pos.hwnd = hDlg; + pos.szModule = dbLastUC_ModuleName; + pos.szNamePrefix = dbLastUC_WindowPosPrefix; + + CallService(MS_UTILS_RESTOREWINDOWPOSITION, 0, (LPARAM)(SAVEWINDOWPOS*)&pos); + } + SendMessage(hDlg, WM_SIZE, 0, 0); WindowList_Add(hWindowList, hDlg, NULL); return TRUE; @@ -526,6 +562,7 @@ INT_PTR ToggleIgnore (WPARAM hContact, LPARAM lParam) extern "C" __declspec(dllexport) int Load(void) { mir_getLP( &pluginInfo ); + mir_getCLI(); CoInitialize(NULL); hWindowList = WindowList_Create(); diff --git a/plugins/RecentContacts/src/RecentContacts.h b/plugins/RecentContacts/src/RecentContacts.h index 4cd9209dd5..fcce1fe640 100644 --- a/plugins/RecentContacts/src/RecentContacts.h +++ b/plugins/RecentContacts/src/RecentContacts.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,7 @@ static char dbLastUC_DateTimeFormatDefault[] = "(%Y-%m-%d %H:%M) "; static char dbLastUC_MaxShownContacts[] = "MaxShownContacts"; static char dbLastUC_IgnoreContact[] = "Ignore"; static char dbLastUC_HideOfflineContacts[] = "HideOfflineContacts"; +static char dbLastUC_WindowAutosize[] = "WindowAutoSize"; static char msLastUC_ShowList[] = "RecentContacts/ShowList"; static char msLastUC_IgnoreOff[] = "RecentContacts/SetIgnoreOff"; @@ -52,6 +54,7 @@ typedef struct _LastUCOptions { int MaxShownContacts; int HideOffline; + int WindowAutoSize; string DateTimeFormat; } LastUCOptions; diff --git a/plugins/RecentContacts/src/Version.h b/plugins/RecentContacts/src/Version.h index d7a9eb4586..7ce8154b7d 100644 --- a/plugins/RecentContacts/src/Version.h +++ b/plugins/RecentContacts/src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 0 #define __RELEASE_NUM 2 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #include diff --git a/plugins/RecentContacts/src/options.cpp b/plugins/RecentContacts/src/options.cpp index e3905cff99..e5c587613d 100644 --- a/plugins/RecentContacts/src/options.cpp +++ b/plugins/RecentContacts/src/options.cpp @@ -12,6 +12,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, (LastUCOpt.HideOffline ? BST_CHECKED : BST_UNCHECKED)); + CheckDlgButton(hwndDlg, IDC_WINDOWAUTOSIZE, (LastUCOpt.WindowAutoSize ? BST_CHECKED : BST_UNCHECKED)); mir_snprintf(str, SIZEOF(str), "%d", LastUCOpt.MaxShownContacts); SetDlgItemTextA(hwndDlg, IDC_SHOWNCONTACTS, str); @@ -41,6 +42,9 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP LastUCOpt.HideOffline = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE); db_set_b(NULL, dbLastUC_ModuleName, dbLastUC_HideOfflineContacts, (BYTE)LastUCOpt.HideOffline); + LastUCOpt.WindowAutoSize = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_WINDOWAUTOSIZE); + db_set_b(NULL, dbLastUC_ModuleName, dbLastUC_WindowAutosize, (BYTE)LastUCOpt.WindowAutoSize); + GetDlgItemTextA(hwndDlg, IDC_SHOWNCONTACTS, str, SIZEOF(str)); LastUCOpt.MaxShownContacts= atoi(str); db_set_b(0,dbLastUC_ModuleName, dbLastUC_MaxShownContacts, LastUCOpt.MaxShownContacts); @@ -60,12 +64,12 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int onOptInitialise(WPARAM wParam, LPARAM lParam) { OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.hInstance = hInst; - odp.pszGroup = LPGEN("Contacts"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_LASTUC_OPT); - odp.pszTitle = msLastUC_ShowListName; - odp.pfnDlgProc = DlgProcOptions; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; + odp.hInstance = hInst; + odp.pszGroup = LPGEN("Contacts"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_LASTUC_OPT); + odp.pszTitle = msLastUC_ShowListName; + odp.pfnDlgProc = DlgProcOptions; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + return 0; } diff --git a/plugins/RecentContacts/src/resource.h b/plugins/RecentContacts/src/resource.h index c5252215eb..df81b25ef0 100644 --- a/plugins/RecentContacts/src/resource.h +++ b/plugins/RecentContacts/src/resource.h @@ -12,6 +12,7 @@ #define IDC_SHOWNCONTACTS 1002 #define IDC_HIDEOFFLINE 1004 #define IDC_DATETIME 1005 +#define IDC_WINDOWAUTOSIZE 1006 // Next default values for new objects // -- cgit v1.2.3