From 76f2743bfae5a9f77351f434434773c8a7b71cf5 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Sun, 30 Dec 2012 17:04:12 +0000 Subject: - StartPosition.txt: - overall fixes and cosmetics (patch from person) git-svn-id: http://svn.miranda-ng.org/main/trunk@2891 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/StartPosition/res/resource.rc | 38 +++++------ plugins/StartPosition/src/Common.h | 2 + plugins/StartPosition/src/main.cpp | 121 +++++++++++++++++----------------- 3 files changed, 83 insertions(+), 78 deletions(-) (limited to 'plugins') diff --git a/plugins/StartPosition/res/resource.rc b/plugins/StartPosition/res/resource.rc index f4215d7de8..9a6b7526a3 100644 --- a/plugins/StartPosition/res/resource.rc +++ b/plugins/StartPosition/res/resource.rc @@ -13,7 +13,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Neutral resources +// NEUTRAL resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL @@ -25,18 +25,18 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "..\\src\\resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""winres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -55,20 +55,20 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Contact List Window Start Position",IDC_STATIC,6,54,298,131,WS_TABSTOP - EDITTEXT IDC_CLTOP,121,68,26,12,ES_AUTOHSCROLL - CONTROL "Left",IDC_CLALIGN1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,151,104,58,10 - CONTROL "Right",IDC_CLALIGN2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,216,104,71,10 - EDITTEXT IDC_CLBOTTOM,121,86,26,12,ES_AUTOHSCROLL - EDITTEXT IDC_CLSIDE,121,102,26,12,ES_AUTOHSCROLL - EDITTEXT IDC_CLWIDTH,121,119,26,12,ES_AUTOHSCROLL - CONTROL "Pixels from Top",IDC_CLTOPENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,70,98,10 - CONTROL "Pixels from Bottom",IDC_CLBOTTOMENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,88,100,10 - CONTROL "Pixels from Side",IDC_CLSIDEENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,104,100,10 - CONTROL "Width",IDC_CLWIDTHENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,120,99,10 - CONTROL "Always start...",IDC_CLSTATEENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,137,273,10 - CONTROL "Minimized to System Tray",IDC_CLSTATE0,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,151,262,10 - CONTROL "Opened",IDC_CLSTATE2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,164,261,10 + GROUPBOX "Contact List Window Start Position",IDC_STATIC,6,37,298,165,WS_TABSTOP + EDITTEXT IDC_CLTOP,128,57,26,12,ES_AUTOHSCROLL + CONTROL "Left",IDC_CLALIGN1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,104,95,10 + CONTROL "Right",IDC_CLALIGN2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,117,94,10 + EDITTEXT IDC_CLBOTTOM,128,73,26,12,ES_AUTOHSCROLL + EDITTEXT IDC_CLSIDE,128,89,26,12,ES_AUTOHSCROLL + EDITTEXT IDC_CLWIDTH,128,130,26,12,ES_AUTOHSCROLL + CONTROL "Pixels from Top",IDC_CLTOPENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,59,98,10 + CONTROL "Pixels from Bottom",IDC_CLBOTTOMENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,75,100,10 + CONTROL "Pixels from Side",IDC_CLSIDEENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,91,100,10 + CONTROL "Width",IDC_CLWIDTHENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,131,99,10 + CONTROL "Always start...",IDC_CLSTATEENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,148,273,10 + CONTROL "Minimized to System Tray",IDC_CLSTATE0,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,162,262,10 + CONTROL "Opened",IDC_CLSTATE2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,175,261,10 END @@ -89,7 +89,7 @@ BEGIN END #endif // APSTUDIO_INVOKED -#endif // Neutral resources +#endif // NEUTRAL resources ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/StartPosition/src/Common.h b/plugins/StartPosition/src/Common.h index 01448f7f88..cceb16c79b 100644 --- a/plugins/StartPosition/src/Common.h +++ b/plugins/StartPosition/src/Common.h @@ -32,6 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "resource.h" #include "version.h" +#define MODULE_NAME "WindowStartPosition" + #define dbERROR -999999 #define RIGHT 1 #define LEFT 0 \ No newline at end of file diff --git a/plugins/StartPosition/src/main.cpp b/plugins/StartPosition/src/main.cpp index 538d05e115..9c3c0794f8 100644 --- a/plugins/StartPosition/src/main.cpp +++ b/plugins/StartPosition/src/main.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "Common.h" +#include "m_clui.h" HINSTANCE hInst; int hLangpack; @@ -59,27 +60,27 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { TranslateDialogDefault(hwndDlg); - if(DBGetContactSettingByte(NULL, "WindowStartPosition", "CLState", 2)) + if(db_get_b(NULL, MODULE_NAME, "CLState", 2)) CheckRadioButton(hwndDlg, IDC_CLSTATE0, IDC_CLSTATE2, IDC_CLSTATE2); else CheckRadioButton(hwndDlg, IDC_CLSTATE0, IDC_CLSTATE2, IDC_CLSTATE0); - if(DBGetContactSettingByte(NULL, "WindowStartPosition", "CLAlign", 1)) + if(db_get_b(NULL, MODULE_NAME, "CLAlign", 1)) CheckRadioButton(hwndDlg, IDC_CLALIGN1, IDC_CLALIGN2, IDC_CLALIGN2); else CheckRadioButton(hwndDlg, IDC_CLALIGN1, IDC_CLALIGN2, IDC_CLALIGN1); - CheckDlgButton(hwndDlg, IDC_CLSTATEENABLE, DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableState", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CLSTATEENABLE, DBGetContactSettingByte(NULL, MODULE_NAME, "CLEnableState", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CLTOPENABLE, DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableTop", 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CLBOTTOMENABLE, DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableBottom", 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CLSIDEENABLE, DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableSide", 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CLWIDTHENABLE, DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableWidth", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CLTOPENABLE, db_get_b(NULL, MODULE_NAME, "CLEnableTop", 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CLBOTTOMENABLE, db_get_b(NULL, MODULE_NAME, "CLEnableBottom", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CLSIDEENABLE, db_get_b(NULL, MODULE_NAME, "CLEnableSide", 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CLWIDTHENABLE, db_get_b(NULL, MODULE_NAME, "CLEnableWidth", 0) ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwndDlg, IDC_CLTOP, DBGetContactSettingDword(NULL, "WindowStartPosition", "CLpixelsTop", 3), TRUE); - SetDlgItemInt(hwndDlg, IDC_CLBOTTOM, DBGetContactSettingDword(NULL, "WindowStartPosition", "CLpixelsBottom", 3), TRUE); - SetDlgItemInt(hwndDlg, IDC_CLSIDE, DBGetContactSettingDword(NULL, "WindowStartPosition", "CLpixelsSide", 3), TRUE); - SetDlgItemInt(hwndDlg, IDC_CLWIDTH, DBGetContactSettingDword(NULL, "WindowStartPosition", "CLWidth", 180), FALSE); + SetDlgItemInt(hwndDlg, IDC_CLTOP, db_get_dw(NULL, MODULE_NAME, "CLpixelsTop", 3), TRUE); + SetDlgItemInt(hwndDlg, IDC_CLBOTTOM, db_get_dw(NULL, MODULE_NAME, "CLpixelsBottom", 3), TRUE); + SetDlgItemInt(hwndDlg, IDC_CLSIDE, db_get_dw(NULL, MODULE_NAME, "CLpixelsSide", 3), TRUE); + SetDlgItemInt(hwndDlg, IDC_CLWIDTH, db_get_dw(NULL, MODULE_NAME, "CLWidth", 180), FALSE); return TRUE; } @@ -92,32 +93,32 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case PSN_APPLY: { /*begin uninstall old settings*/ - if(DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableTop", dbERROR) == dbERROR) { - DBDeleteContactSetting(NULL, "WindowStartPosition", "CLEnable"); - DBDeleteContactSetting(NULL, "WindowStartPosition", "CLuseLastWidth"); + if(db_get_b(NULL, MODULE_NAME, "CLEnableTop", dbERROR) == dbERROR) { + db_unset(NULL, MODULE_NAME, "CLEnable"); + db_unset(NULL, MODULE_NAME, "CLuseLastWidth"); } /*end uninstall old settings*/ if(IsDlgButtonChecked(hwndDlg, IDC_CLSTATE2)) - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLState", 2); + db_set_b(NULL, MODULE_NAME, "CLState", 2); else - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLState", 0); + db_set_b(NULL, MODULE_NAME, "CLState", 0); if(IsDlgButtonChecked(hwndDlg, IDC_CLALIGN1)) - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLAlign", 0); + db_set_b(NULL, MODULE_NAME, "CLAlign", 0); else - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLAlign", 1); + db_set_b(NULL, MODULE_NAME, "CLAlign", 1); - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLEnableState", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLSTATEENABLE)); + db_set_b(NULL, MODULE_NAME, "CLEnableState", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLSTATEENABLE)); - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLEnableTop", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLTOPENABLE)); - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLEnableBottom", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLBOTTOMENABLE)); - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLEnableSide", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLSIDEENABLE)); - DBWriteContactSettingByte(NULL, "WindowStartPosition", "CLEnableWidth", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLWIDTHENABLE)); - DBWriteContactSettingDword(NULL, "WindowStartPosition", "CLWidth", GetDlgItemInt(hwndDlg, IDC_CLWIDTH, NULL, FALSE)); - DBWriteContactSettingDword(NULL, "WindowStartPosition", "CLpixelsTop", GetDlgItemInt(hwndDlg, IDC_CLTOP, NULL, TRUE)); - DBWriteContactSettingDword(NULL, "WindowStartPosition", "CLpixelsBottom", GetDlgItemInt(hwndDlg, IDC_CLBOTTOM, NULL, TRUE)); - DBWriteContactSettingDword(NULL, "WindowStartPosition", "CLpixelsSide", GetDlgItemInt(hwndDlg, IDC_CLSIDE, NULL, TRUE)); + db_set_b(NULL, MODULE_NAME, "CLEnableTop", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLTOPENABLE)); + db_set_b(NULL, MODULE_NAME, "CLEnableBottom", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLBOTTOMENABLE)); + db_set_b(NULL, MODULE_NAME, "CLEnableSide", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLSIDEENABLE)); + db_set_b(NULL, MODULE_NAME, "CLEnableWidth", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLWIDTHENABLE)); + db_set_dw(NULL, MODULE_NAME, "CLWidth", GetDlgItemInt(hwndDlg, IDC_CLWIDTH, NULL, FALSE)); + db_set_dw(NULL, MODULE_NAME, "CLpixelsTop", GetDlgItemInt(hwndDlg, IDC_CLTOP, NULL, TRUE)); + db_set_dw(NULL, MODULE_NAME, "CLpixelsBottom", GetDlgItemInt(hwndDlg, IDC_CLBOTTOM, NULL, TRUE)); + db_set_dw(NULL, MODULE_NAME, "CLpixelsSide", GetDlgItemInt(hwndDlg, IDC_CLSIDE, NULL, TRUE)); return TRUE; } @@ -135,7 +136,7 @@ int OptInit(WPARAM wParam, LPARAM lParam) odp.hInstance = hInst; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.pszGroup = LPGEN("Contact List"); - odp.pszTitle = LPGEN("Window Start Position"); + odp.pszTitle = LPGEN("Start Position"); odp.pfnDlgProc = OptionsDlgProc; odp.flags = ODPF_BOLDGROUPS; Options_AddPage(wParam, &odp); @@ -149,50 +150,52 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam) SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkArea, 0); - int clEnableTop = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableTop", 1); - int clEnableBottom = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableBottom", 1); - int clEnableSide = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableSide", 1); - int clEnableWidth = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableWidth", 0); + BYTE clEnableTop = db_get_b(NULL, MODULE_NAME, "CLEnableTop", 1); + BYTE clEnableBottom = db_get_b(NULL, MODULE_NAME, "CLEnableBottom", 1); + BYTE clEnableSide = db_get_b(NULL, MODULE_NAME, "CLEnableSide", 1); + BYTE clEnableWidth = db_get_b(NULL, MODULE_NAME, "CLEnableWidth", 0); - int clTop = DBGetContactSettingDword(NULL, "WindowStartPosition", "CLpixelsTop", 3); - int clBottom = DBGetContactSettingDword(NULL, "WindowStartPosition", "CLpixelsBottom", 3); - int clSide = DBGetContactSettingDword(NULL, "WindowStartPosition", "CLpixelsSide", 3); - int clAlign = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLAlign", RIGHT); - int clWidth = DBGetContactSettingDword(NULL, "WindowStartPosition", "CLWidth", 180); + DWORD clTop = db_get_dw(NULL, MODULE_NAME, "CLpixelsTop", 3); + DWORD clBottom = db_get_dw(NULL, MODULE_NAME, "CLpixelsBottom", 3); + DWORD clSide = db_get_dw(NULL, MODULE_NAME, "CLpixelsSide", 3); + BYTE clAlign = db_get_b(NULL, MODULE_NAME, "CLAlign", RIGHT); + DWORD clWidth = db_get_dw(NULL, MODULE_NAME, "CLWidth", 180); - int clEnableState = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLEnableState", 0); - int clState = DBGetContactSettingByte(NULL, "WindowStartPosition", "CLState", 2); + BYTE clEnableState = db_get_b(NULL, MODULE_NAME, "CLEnableState", 0); + BYTE clState = db_get_b(NULL, MODULE_NAME, "CLState", 2); - if(clEnableState) - DBWriteContactSettingByte(NULL,"CList", "State", (BYTE)clState); + if(clEnableState == 1) + db_set_b(NULL,"CList", "State", clState); - if(clEnableWidth) { - if(clWidth > 0) - DBWriteContactSettingDword(NULL, "CList", "Width", clWidth); - } else { - clWidth = DBGetContactSettingDword(NULL, "CList", "Width", 180); - } + if(clEnableWidth == 1 && clWidth > 0) + db_set_dw(NULL, "CList", "Width", clWidth); + else + clWidth = db_get_dw(NULL, "CList", "Width", 180); - if(clEnableTop || clEnableBottom || clEnableSide) - DBWriteContactSettingByte(NULL,"CList", "Docked", 0); - - if(clEnableTop) - DBWriteContactSettingDword(NULL, "CList", "y", clTop); + if(clEnableTop == 1 || clEnableBottom == 1 || clEnableSide == 1) + db_set_b(NULL,"CList", "Docked", 0); + db_set_b(NULL,"CLUI", "AutoSize", 0); + db_set_b(NULL,"CLUI", "DockToSides", 0); + + if(clEnableTop == 1) + db_set_dw(NULL, "CList", "y", clTop); //thx ValeraVi - if(clEnableBottom) { - if(clEnableTop) - DBWriteContactSettingDword(NULL, "CList", "Height", (WorkArea.bottom - WorkArea.top - clTop - clBottom)); + if(clEnableBottom == 1) { + if(clEnableTop == 1) + db_set_dw(NULL, "CList", "Height", (WorkArea.bottom - WorkArea.top - (LONG)clTop - (LONG)clBottom)); else - DBWriteContactSettingDword(NULL, "CList", "y", (WorkArea.bottom - clBottom - (int)DBGetContactSettingDword(NULL, "CList", "Height", 0))); + db_set_dw(NULL, "CList", "y", (WorkArea.bottom - (LONG)clBottom - (LONG)db_get_dw(NULL, "CList", "Height", 0))); } - if(clEnableSide) { + if(clEnableSide == 1 ) { if(clAlign == LEFT) - DBWriteContactSettingDword(NULL, "CList", "x", (WorkArea.left + clSide)); + db_set_dw(NULL, "CList", "x", (WorkArea.left + clSide)); else - DBWriteContactSettingDword(NULL, "CList", "x", (WorkArea.right - clWidth - clSide)); + db_set_dw(NULL, "CList", "x", (WorkArea.right - clWidth - clSide)); } + HWND hClist = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + MoveWindow(hClist, (int)db_get_dw(NULL, "CList", "x", 100), (int)db_get_dw(NULL, "CList", "y", 100), (int)clWidth, (int)db_get_dw(NULL, "CList", "Height", 0), 0); return 0; } -- cgit v1.2.3