summaryrefslogtreecommitdiff
path: root/src/modules/options
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-30 19:44:31 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-30 19:44:31 +0000
commit26e9cc0993388e1c40dc276a6d59ce60fb9cee5b (patch)
treea4a6cf208a3f000c2a80ca075381062e87da29d1 /src/modules/options
parentb52dd1c1f38d1aeeb01c303d405a51afa82efe3b (diff)
fix for options dialog: current options tree item might not be visible after opening
git-svn-id: http://svn.miranda-ng.org/main/trunk@7433 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/options')
-rw-r--r--src/modules/options/options.cpp636
1 files changed, 305 insertions, 331 deletions
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp
index 5101a813af..4cd938183f 100644
--- a/src/modules/options/options.cpp
+++ b/src/modules/options/options.cpp
@@ -119,7 +119,7 @@ HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name)
tvi.hItem = TreeView_GetRoot(hwndTree);
while (tvi.hItem != NULL) {
SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi);
- if ( !_tcsicmp(str, name))
+ if (!_tcsicmp(str, name))
return tvi.hItem;
tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
@@ -137,7 +137,7 @@ static HTREEITEM FindNamedTreeItemAtChildren(HWND hwndTree, HTREEITEM hItem, con
tvi.hItem = TreeView_GetChild(hwndTree, hItem);
while (tvi.hItem != NULL) {
SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM)&tvi);
- if ( !_tcsicmp(str, name))
+ if (!_tcsicmp(str, name))
return tvi.hItem;
tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
@@ -150,7 +150,7 @@ static BOOL CALLBACK BoldGroupTitlesEnumChildren(HWND hwnd, LPARAM lParam)
TCHAR szClass[64];
GetClassName(hwnd, szClass, SIZEOF(szClass));
- if ( !lstrcmp(szClass, _T("Button")) && (GetWindowLongPtr(hwnd, GWL_STYLE)&0x0F) == BS_GROUPBOX)
+ if (!lstrcmp(szClass, _T("Button")) && (GetWindowLongPtr(hwnd, GWL_STYLE) & 0x0F) == BS_GROUPBOX)
SendMessage(hwnd, WM_SETFONT, lParam, 0);
return TRUE;
}
@@ -164,13 +164,13 @@ static void SaveOptionsTreeState(HWND hdlg)
tvi.mask = TVIF_TEXT | TVIF_STATE;
tvi.pszText = str;
tvi.cchTextMax = SIZEOF(str);
- tvi.hItem = TreeView_GetRoot( GetDlgItem(hdlg, IDC_PAGETREE));
+ tvi.hItem = TreeView_GetRoot(GetDlgItem(hdlg, IDC_PAGETREE));
while (tvi.hItem != NULL) {
- if (SendMessageA( GetDlgItem(hdlg, IDC_PAGETREE), TVM_GETITEMA, 0, (LPARAM)&tvi)) {
+ if (SendMessageA(GetDlgItem(hdlg, IDC_PAGETREE), TVM_GETITEMA, 0, (LPARAM)&tvi)) {
mir_snprintf(buf, SIZEOF(buf), "%s%s", OPTSTATE_PREFIX, str);
- db_set_b(NULL, "Options", buf, (BYTE)((tvi.state&TVIS_EXPANDED)?1:0));
+ db_set_b(NULL, "Options", buf, (BYTE)((tvi.state & TVIS_EXPANDED) ? 1 : 0));
}
- tvi.hItem = TreeView_GetNextSibling( GetDlgItem(hdlg, IDC_PAGETREE), tvi.hItem);
+ tvi.hItem = TreeView_GetNextSibling(GetDlgItem(hdlg, IDC_PAGETREE), tvi.hItem);
}
}
@@ -197,21 +197,17 @@ static int lstrcmpnull(TCHAR *str1, TCHAR *str2)
return lstrcmp(str1, str2);
}
-static TCHAR *GetPluginName(HINSTANCE hInstance, TCHAR *buffer, int size)
+static TCHAR* GetPluginName(HINSTANCE hInstance, TCHAR *buffer, int size)
{
TCHAR tszModuleName[MAX_PATH];
GetModuleFileName(hInstance, tszModuleName, SIZEOF(tszModuleName));
TCHAR *dllName = _tcsrchr(tszModuleName, '\\');
- if ( !dllName)
- {
+ if (!dllName)
dllName = tszModuleName;
- }
- else {
+ else
dllName++;
- }
_tcsncpy(buffer, dllName, size);
-
return buffer;
}
@@ -227,8 +223,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd
if (enableKeywordFiltering) {
if (current)
hWnd = page->hwnd;
- else
- {
+ else {
hWnd = CreateDialogIndirectParamA(page->hInst, page->pTemplate, hWndParent, page->dlgProc, page->dwInitParam); //create the options dialog page so we can parse it
ShowWindow(hWnd, SW_HIDE); //make sure it's hidden
}
@@ -236,11 +231,8 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd
DWORD key = GetPluginPageHash(page); //get the plugin page hash
- TCHAR *PluginFullName = NULL;
- char * temp = GetPluginNameByInstance(page->hInst);
- if (temp) PluginFullName = mir_a2t(temp);
- GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->hInst, pluginName, SIZEOF(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, PluginFullName);
- if (PluginFullName) mir_free(PluginFullName);
+ char *temp = GetPluginNameByInstance(page->hInst);
+ GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->hInst, pluginName, SIZEOF(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, _A2T(temp));
if (enableKeywordFiltering && !current)
DestroyWindow(hWnd); //destroy the page, we're done with it
@@ -248,9 +240,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd
static int MatchesFilter(const OptionsPageData *page, TCHAR *szFilterString)
{
- DWORD key = GetPluginPageHash(page);
-
- return ContainsFilterString(key, szFilterString);
+ return ContainsFilterString(GetPluginPageHash(page), szFilterString);
}
static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -288,17 +278,17 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA
RECT rc2;
GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &rc, &rc2);
- rc2.top = 2 * rc.top - rc2.top;
- rc2.left = 2 * rc.left - rc2.left;
+ rc2.top = 2 * rc.top - rc2.top;
+ rc2.left = 2 * rc.left - rc2.left;
rc2.bottom = 2 * rc.bottom - rc2.bottom;
- rc2.right = 2 * rc.right - rc2.right;
+ rc2.right = 2 * rc.right - rc2.right;
DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &rc2, &rc);
- HFONT hFont = (HFONT) SendMessage(hWnd, WM_GETFONT, 0, 0);
- HFONT oldFont = (HFONT) SelectObject(hdc, hFont);
+ HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
+ HFONT oldFont = (HFONT)SelectObject(hdc, hFont);
wchar_t *bufW = mir_t2u(buf);
- DrawThemeText(hTheme, hdc, EP_EDITTEXT, ETS_DISABLED, bufW, -1, 0, 0, &rc);
+ DrawThemeText(hTheme, hdc, EP_EDITTEXT, ETS_DISABLED, bufW, -1, 0, 0, &rc);
mir_free(bufW);
SelectObject(hdc, oldFont);
@@ -308,9 +298,9 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA
SetBkMode(hdc, oldMode);
- if ( !bDrawnByTheme) {
- HFONT hFont = (HFONT) SendMessage(hWnd, WM_GETFONT, 0, 0);
- HFONT oldFont = (HFONT) SelectObject(hdc, hFont);
+ if (!bDrawnByTheme) {
+ HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
+ HFONT oldFont = (HFONT)SelectObject(hdc, hFont);
SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
int oldMode = SetBkMode(hdc, TRANSPARENT);
@@ -329,7 +319,8 @@ static BOOL CheckPageShow(HWND hdlg, OptionsDlgData* dat, int i)
{
OptionsPageData* opd = dat->arOpd[i];
- if (dat->szFilterString && dat->szFilterString[0] && !MatchesFilter(opd, dat->szFilterString)) return FALSE;
+ if (dat->szFilterString && dat->szFilterString[0] && !MatchesFilter(opd, dat->szFilterString))
+ return FALSE;
return TRUE;
}
@@ -341,7 +332,7 @@ static BOOL IsAeroMode()
static void FreeOptionsData(OptionsPageInit* popi)
{
- for (int i=0; i < popi->pageCount; i++) {
+ for (int i = 0; i < popi->pageCount; i++) {
mir_free((char*)popi->odp[i].pszTitle);
mir_free(popi->odp[i].pszGroup);
mir_free(popi->odp[i].pszTab);
@@ -362,7 +353,7 @@ static void FreeOptionsPageData(OptionsPageData *opd)
mir_free(opd);
}
-static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = WM_PRINT, LPARAM lpFlags = PRF_CLIENT|PRF_NONCLIENT)
+static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = WM_PRINT, LPARAM lpFlags = PRF_CLIENT | PRF_NONCLIENT)
{
HBITMAP hBmp, hOldBmp;
RECT rc; GetClientRect(hwnd, &rc);
@@ -388,8 +379,8 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg =
// Fix alpha channel
GdiFlush();
- for (int i=0; i < rc.right*rc.bottom; i++, pBits += 4)
- if ( !pBits[3]) pBits[3] = 255;
+ for (int i = 0; i < rc.right*rc.bottom; i++, pBits += 4)
+ if (!pBits[3]) pBits[3] = 255;
//Copy to output
BitBlt(hdc, 0, 0, rc.right, rc.bottom, tempDC, 0, 0, SRCCOPY);
@@ -402,7 +393,7 @@ static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam
{
switch (msg) {
case WM_CTLCOLOREDIT:
- if ( !GetPropA((HWND)lParam, "Miranda.AeroRender.Active"))
+ if (!GetPropA((HWND)lParam, "Miranda.AeroRender.Active"))
RedrawWindow((HWND)lParam, NULL, NULL, RDW_INVALIDATE);
break;
@@ -415,12 +406,12 @@ static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam
return TRUE;
case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- AeroPaintControl(hwnd, hdc, AeroPaintSubclassProc);
- EndPaint(hwnd, &ps);
- }
+ {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hwnd, &ps);
+ AeroPaintControl(hwnd, hdc, AeroPaintSubclassProc);
+ EndPaint(hwnd, &ps);
+ }
return TRUE;
case WM_DESTROY:
@@ -433,17 +424,17 @@ static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam
static void CALLBACK FilterSearchTimerFunc(HWND hwnd, UINT, UINT_PTR, DWORD)
{
OptionsDlgData* dat = (OptionsDlgData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if ( !dat)
+ if (!dat)
return;
if (hFilterSearchWnd == NULL)
- hFilterSearchWnd = CreateWindowA("STATIC", "Test", WS_OVERLAPPED|WS_DISABLED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), 0); // Fake window to keep option page focused
+ hFilterSearchWnd = CreateWindowA("STATIC", "Test", WS_OVERLAPPED | WS_DISABLED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), 0); // Fake window to keep option page focused
if (FilterPage < dat->arOpd.getCount())
FindFilterStrings(TRUE, dat->currentPage == FilterPage, hFilterSearchWnd, dat->arOpd[FilterPage]);
FilterPage++;
- FilterLoadProgress = FilterPage*100/((dat->arOpd.getCount()) ? dat->arOpd.getCount() : FilterPage);
+ FilterLoadProgress = FilterPage * 100 / ((dat->arOpd.getCount()) ? dat->arOpd.getCount() : FilterPage);
if (FilterPage >= dat->arOpd.getCount()) {
KillTimer(hwnd, FilterTimerId);
FilterTimerId = 0;
@@ -452,7 +443,7 @@ static void CALLBACK FilterSearchTimerFunc(HWND hwnd, UINT, UINT_PTR, DWORD)
DestroyWindow(hFilterSearchWnd);
hFilterSearchWnd = NULL;
}
- RedrawWindow( GetDlgItem(hwnd, IDC_KEYWORD_FILTER), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
+ RedrawWindow(GetDlgItem(hwnd, IDC_KEYWORD_FILTER), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
}
static void ExecuteFindFilterStringsTimer(HWND hdlg)
@@ -467,13 +458,13 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat)
{
HINSTANCE *KnownInstances = (HINSTANCE*)alloca(sizeof(HINSTANCE)*dat->arOpd.getCount());
int countKnownInst = 0;
- SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_RESETCONTENT, 0, 0);
- int index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, 0, (LPARAM)TranslateT(ALL_MODULES_FILTER));
- SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, 0);
- index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, 0, (LPARAM)TranslateT(CORE_MODULES_FILTER));
- SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)hInst);
+ SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_RESETCONTENT, 0, 0);
+ int index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_ADDSTRING, 0, (LPARAM)TranslateT(ALL_MODULES_FILTER));
+ SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_SETITEMDATA, (WPARAM)index, 0);
+ index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_ADDSTRING, 0, (LPARAM)TranslateT(CORE_MODULES_FILTER));
+ SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_SETITEMDATA, (WPARAM)index, (LPARAM)hInst);
TCHAR *tszModuleName = (TCHAR*)alloca(MAX_PATH*sizeof(TCHAR));
- for (int i=0; i < dat->arOpd.getCount(); i++) {
+ for (int i = 0; i < dat->arOpd.getCount(); i++) {
FindFilterStrings(FALSE, FALSE, hDlg, dat->arOpd[i]); // only modules name (fast enougth)
HINSTANCE inst = dat->arOpd[i]->hInst;
@@ -481,7 +472,7 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat)
continue;
int j;
- for (j = 0; j<countKnownInst; j++)
+ for (j = 0; j < countKnownInst; j++)
if (KnownInstances[j] == inst)
break;
if (j != countKnownInst)
@@ -491,19 +482,12 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat)
countKnownInst++;
GetModuleFileName(inst, tszModuleName, MAX_PATH);
- TCHAR *dllName = NULL;
- {
- char *name = GetPluginNameByInstance(inst);
- if (name)
- dllName = mir_a2t(name);
- }
-
- if ( !dllName) dllName = mir_tstrdup(_tcsrchr(tszModuleName, _T('\\')));
- if ( !dllName) dllName = mir_tstrdup(tszModuleName);
-
+ TCHAR *dllName = mir_a2t(GetPluginNameByInstance(inst));
+ if (!dllName) dllName = mir_tstrdup(_tcsrchr(tszModuleName, _T('\\')));
+ if (!dllName) dllName = mir_tstrdup(tszModuleName);
if (dllName) {
- index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, 0, (LPARAM)dllName);
- SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)inst);
+ index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_ADDSTRING, 0, (LPARAM)dllName);
+ SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT)CB_SETITEMDATA, (WPARAM)index, (LPARAM)inst);
mir_free(dllName);
}
}
@@ -511,7 +495,187 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat)
FilterLoadProgress = 100;
}
-static BOOL IsInsideTab(HWND hdlg, OptionsDlgData * dat, int i)
+static void RebuildPageTree(HWND hdlg, OptionsDlgData *dat)
+{
+ BOOL bRemoveFocusFromFilter = FALSE;
+ HINSTANCE FilterInst = NULL;
+
+ LPARAM oldSel = SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, CB_GETEDITSEL, 0, 0);
+ GetDlgItemText(hdlg, IDC_KEYWORD_FILTER, dat->szFilterString, SIZEOF(dat->szFilterString));
+
+ //if filter string is set to all modules then make the filter string empty (this will return all modules)
+ if (_tcscmp(dat->szFilterString, TranslateT(ALL_MODULES_FILTER)) == 0) {
+ dat->szFilterString[0] = 0;
+ bRemoveFocusFromFilter = TRUE;
+ }
+ //if filter string is set to core modules replace it with the name of the executable (this will return all core modules)
+ else if (_tcscmp(dat->szFilterString, TranslateT(CORE_MODULES_FILTER)) == 0) {
+ //replace string with process name - that will show core settings
+ TCHAR szFileName[300];
+ GetModuleFileName(NULL, szFileName, SIZEOF(szFileName));
+ TCHAR *pos = _tcsrchr(szFileName, _T('\\'));
+ if (pos)
+ pos++;
+ else
+ pos = szFileName;
+
+ _tcsncpy(dat->szFilterString, pos, SIZEOF(dat->szFilterString));
+ }
+ else {
+ int sel = SendMessage(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), (UINT)CB_GETCURSEL, 0, 0);
+ if (sel != -1) {
+ HINSTANCE hinst = (HINSTANCE)SendMessage(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), (UINT)CB_GETITEMDATA, sel, 0);
+ TCHAR szFileName[300];
+ GetModuleFileName(hinst, szFileName, SIZEOF(szFileName));
+ TCHAR *pos = _tcsrchr(szFileName, _T('\\'));
+ if (pos) pos++;
+ else pos = szFileName;
+ _tcsncpy(dat->szFilterString, pos, SIZEOF(dat->szFilterString));
+ }
+ }
+
+ _tcslwr_locale(dat->szFilterString); //all strings are stored as lowercase ... make sure filter string is lowercase too
+
+ HWND hwndTree = GetDlgItem(hdlg, IDC_PAGETREE);
+ SendMessage(hwndTree, WM_SETREDRAW, FALSE, 0);
+
+ HWND oldWnd = NULL;
+ HWND oldTab = NULL;
+
+ OptionsPageData *opd = dat->getCurrent();
+ if (opd != NULL) {
+ oldWnd = opd->hwnd;
+ if (opd->insideTab)
+ oldTab = GetDlgItem(hdlg, IDC_TAB);
+ }
+
+ dat->hCurrentPage = NULL;
+
+ TreeView_SelectItem(hwndTree, NULL);
+ TreeView_DeleteAllItems(hwndTree);
+
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = NULL;
+ tvis.hInsertAfter = TVI_SORT;
+ tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
+ tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
+ for (int i = 0; i < dat->arOpd.getCount(); i++) {
+ static TCHAR *fullTitle = NULL;
+ mir_free(fullTitle); fullTitle = NULL;
+ if (!CheckPageShow(hdlg, dat, i))
+ continue;
+
+ opd = dat->arOpd[i];
+ TCHAR *ptszGroup = TranslateTH(opd->hLangpack, opd->ptszGroup);
+ TCHAR *ptszTitle = opd->getString(opd->ptszTitle);
+ TCHAR *ptszTab = TranslateTH(opd->hLangpack, opd->ptszTab);
+
+ tvis.hParent = NULL;
+ if (FilterInst != NULL) {
+ size_t sz = ptszGroup ? _tcslen(ptszGroup) + 1 : 0;
+ if (sz) sz += 3;
+ sz += ptszTitle ? _tcslen(ptszTitle) + 1 : 0;
+ fullTitle = (TCHAR*)mir_alloc(sz*sizeof(TCHAR));
+ mir_sntprintf(fullTitle, sz, (ptszGroup && ptszTitle) ? _T("%s - %s") : _T("%s%s"),
+ ptszGroup ? ptszGroup : _T(""),
+ ptszTitle ? ptszTitle : _T(""));
+ }
+ TCHAR *useTitle = fullTitle ? fullTitle : ptszTitle;
+ if (ptszGroup != NULL && FilterInst == NULL) {
+ tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, ptszGroup);
+ if (tvis.hParent == NULL) {
+ tvis.item.lParam = -1;
+ tvis.item.pszText = ptszGroup;
+ tvis.hParent = TreeView_InsertItem(hwndTree, &tvis);
+ }
+ }
+ else {
+ TVITEM tvi;
+ tvi.hItem = FindNamedTreeItemAtRoot(hwndTree, useTitle);
+ if (tvi.hItem != NULL) {
+ if (i == dat->currentPage) dat->hCurrentPage = tvi.hItem;
+ tvi.mask = TVIF_PARAM;
+ TreeView_GetItem(hwndTree, &tvi);
+ if (tvi.lParam == -1) {
+ tvi.lParam = i;
+ TreeView_SetItem(hwndTree, &tvi);
+ continue;
+ }
+ }
+ }
+
+ if (ptszTab != NULL) {
+ HTREEITEM hItem;
+ if (tvis.hParent == NULL)
+ hItem = FindNamedTreeItemAtRoot(hwndTree, useTitle);
+ else
+ hItem = FindNamedTreeItemAtChildren(hwndTree, tvis.hParent, useTitle);
+ if (hItem != NULL) {
+ if (i == dat->currentPage) {
+ TVITEM tvi;
+ tvi.hItem = hItem;
+ tvi.mask = TVIF_PARAM;
+ tvi.lParam = dat->currentPage;
+ TreeView_SetItem(hwndTree, &tvi);
+ dat->hCurrentPage = hItem;
+ }
+ continue;
+ }
+ }
+
+ tvis.item.pszText = useTitle;
+ tvis.item.lParam = i;
+ opd->hTreeItem = TreeView_InsertItem(hwndTree, &tvis);
+ if (i == dat->currentPage)
+ dat->hCurrentPage = opd->hTreeItem;
+
+ if (fullTitle) mir_free(fullTitle);
+ fullTitle = NULL;
+ }
+
+ char str[128];
+ TVITEMA tvi;
+ tvi.mask = TVIF_TEXT | TVIF_STATE;
+ tvi.pszText = str;
+ tvi.cchTextMax = SIZEOF(str);
+ tvi.hItem = TreeView_GetRoot(hwndTree);
+ while (tvi.hItem != NULL) {
+ if (SendMessageA(hwndTree, TVM_GETITEMA, 0, (LPARAM)&tvi)) {
+ char buf[130];
+ mir_snprintf(buf, SIZEOF(buf), "%s%s", OPTSTATE_PREFIX, str);
+ if (!db_get_b(NULL, "Options", buf, 1))
+ TreeView_Expand(hwndTree, tvi.hItem, TVE_COLLAPSE);
+ }
+ tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
+ }
+
+ if (dat->hCurrentPage == NULL) {
+ dat->hCurrentPage = TreeView_GetRoot(hwndTree);
+ dat->currentPage = -1;
+ }
+ TreeView_SelectItem(hwndTree, dat->hCurrentPage);
+
+ if (oldWnd) {
+ opd = dat->getCurrent();
+ if (opd && oldWnd != opd->hwnd) {
+ ShowWindow(oldWnd, SW_HIDE);
+ if (oldTab && (opd == NULL || !opd->insideTab))
+ ShowWindow(oldTab, SW_HIDE);
+ }
+ }
+
+ if (dat->szFilterString[0] == 0) // Clear the keyword combo box
+ SetWindowText(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), _T(""));
+ if (!bRemoveFocusFromFilter)
+ SetFocus(GetDlgItem(hdlg, IDC_KEYWORD_FILTER)); //set the focus back to the combo box
+
+ SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, CB_SETEDITSEL, 0, oldSel); //but don't select any of the text
+
+ SendMessage(hwndTree, WM_SETREDRAW, TRUE, 0);
+ TreeView_EnsureVisible(hwndTree, dat->hCurrentPage);
+}
+
+static BOOL IsInsideTab(HWND hdlg, OptionsDlgData *dat, int i)
{
OptionsPageData *opd = dat->arOpd[i];
int pages = 0;
@@ -519,8 +683,8 @@ static BOOL IsInsideTab(HWND hdlg, OptionsDlgData * dat, int i)
// Count tabs to calc position
for (int j = 0; j < dat->arOpd.getCount() && pages < 2; j++) {
OptionsPageData* opd2 = dat->arOpd[j];
- if ( !CheckPageShow(hdlg, dat, j)) continue;
- if ( lstrcmp(opd2->ptszTitle, opd->ptszTitle) || lstrcmpnull(opd2->ptszGroup, opd->ptszGroup))
+ if (!CheckPageShow(hdlg, dat, j)) continue;
+ if (lstrcmp(opd2->ptszTitle, opd->ptszTitle) || lstrcmpnull(opd2->ptszGroup, opd->ptszGroup))
continue;
pages++;
}
@@ -546,11 +710,11 @@ static bool LoadOptionsPage(OPTIONSDIALOGPAGE *src, OptionsPageData *dst)
//this feels like an access violation, and is according to boundschecker
//...but it works - for now
//may well have to remove and sort out the original dialogs
- dte->style &= ~(WS_VISIBLE|WS_CHILD|WS_POPUP|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|DS_MODALFRAME|DS_CENTER);
+ dte->style &= ~(WS_VISIBLE | WS_CHILD | WS_POPUP | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER);
dte->style |= WS_CHILD;
}
else {
- dst->pTemplate->style &= ~(WS_VISIBLE|WS_CHILD|WS_POPUP|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|DS_MODALFRAME|DS_CENTER);
+ dst->pTemplate->style &= ~(WS_VISIBLE | WS_CHILD | WS_POPUP | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER);
dst->pTemplate->style |= WS_CHILD;
}
dst->dlgProc = src->pfnDlgProc;
@@ -593,9 +757,9 @@ static void LoadOptionsModule(HWND hdlg, OptionsDlgData *dat, HINSTANCE hInst)
if (opi.pageCount == 0)
return;
- for (int i=0; i < opi.pageCount; i++) {
+ for (int i = 0; i < opi.pageCount; i++) {
OptionsPageData* opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
- if ( LoadOptionsPage(&opi.odp[i], opd))
+ if (LoadOptionsPage(&opi.odp[i], opd))
dat->arOpd.insert(opd);
else
mir_free(opd);
@@ -609,7 +773,7 @@ static void UnloadOptionsModule(HWND hdlg, OptionsDlgData *dat, HINSTANCE hInst)
{
bool bToRebuildTree = false;
- for (int i=dat->arOpd.getCount()-1; i >= 0; i--) {
+ for (int i = dat->arOpd.getCount() - 1; i >= 0; i--) {
OptionsPageData* opd = dat->arOpd[i];
if (opd->hInst != hInst)
continue;
@@ -644,17 +808,15 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
- if ( !ServiceExists(MS_MODERNOPT_SHOW))
- ShowWindow( GetDlgItem(hdlg, IDC_MODERN), FALSE);
+ if (!ServiceExists(MS_MODERNOPT_SHOW))
+ ShowWindow(GetDlgItem(hdlg, IDC_MODERN), FALSE);
{
PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam;
OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)psh->pStartPage;
- TCHAR *lastPage = NULL, *lastGroup = NULL, *lastTab = NULL;
- DBVARIANT dbv;
COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
- GetComboBoxInfo( GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi);
+ GetComboBoxInfo(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi);
mir_subclassWindow(cbi.hwndItem, OptionsFilterSubclassProc);
if (IsAeroMode()) {
@@ -664,7 +826,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
Utils_RestoreWindowPositionNoSize(hdlg, NULL, "Options", "");
Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_OPTIONS);
- EnableWindow( GetDlgItem(hdlg, IDC_APPLY), FALSE);
+ EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE);
dat = new OptionsDlgData;
SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)dat);
SetWindowText(hdlg, psh->pszCaption);
@@ -677,53 +839,42 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
dat->hPluginLoad = HookEventMessage(ME_SYSTEM_MODULELOAD, hdlg, HM_MODULELOAD);
dat->hPluginUnload = HookEventMessage(ME_SYSTEM_MODULEUNLOAD, hdlg, HM_MODULEUNLOAD);
-
dat->currentPage = -1;
+
+ ptrT lastPage, lastGroup, lastTab;
if (ood->pszPage == NULL) {
- if ( !db_get_ts(NULL, "Options", "LastPage", &dbv)) {
- lastPage = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ lastPage = db_get_tsa(NULL, "Options", "LastPage");
- if (ood->pszGroup == NULL) {
- if ( !db_get_ts(NULL, "Options", "LastGroup", &dbv)) {
- lastGroup = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- }
- else lastGroup = mir_a2t(ood->pszGroup);
+ if (ood->pszGroup == NULL)
+ lastGroup = db_get_tsa(NULL, "Options", "LastGroup");
+ else
+ lastGroup = mir_a2t(ood->pszGroup);
}
else {
lastPage = mir_a2t(ood->pszPage);
- lastGroup = (ood->pszGroup == NULL) ? NULL : mir_a2t(ood->pszGroup);
+ lastGroup = mir_a2t(ood->pszGroup);
}
- if (ood->pszTab == NULL) {
- if ( !db_get_ts(NULL, "Options", "LastTab", &dbv)) {
- lastTab = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- }
- else lastTab = mir_a2t(ood->pszTab);
+ if (ood->pszTab == NULL)
+ lastTab = db_get_tsa(NULL, "Options", "LastTab");
+ else
+ lastTab = mir_a2t(ood->pszTab);
OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp;
- for (size_t i=0; i < psh->nPages; i++, odp++) {
+ for (UINT i = 0; i < psh->nPages; i++, odp++) {
opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
- if ( !LoadOptionsPage(odp, opd)) {
+ if (!LoadOptionsPage(odp, opd)) {
mir_free(opd);
continue;
}
dat->arOpd.insert(opd);
- if ( !lstrcmp(lastPage, odp->ptszTitle) && !lstrcmpnull(lastGroup, odp->ptszGroup) &&
- ((ood->pszTab == NULL && dat->currentPage == -1) || !lstrcmpnull(lastTab, odp->ptszTab)))
- dat->currentPage = (int)i;
+ if (!lstrcmp(lastPage, odp->ptszTitle) && !lstrcmpnull(lastGroup, odp->ptszGroup))
+ if ((ood->pszTab == NULL && dat->currentPage == -1) || !lstrcmpnull(lastTab, odp->ptszTab))
+ dat->currentPage = (int)i;
}
- mir_free(lastGroup);
- mir_free(lastPage);
- mir_free(lastTab);
- GetWindowRect( GetDlgItem(hdlg, IDC_STNOPAGE), &dat->rcDisplay);
+ GetWindowRect(GetDlgItem(hdlg, IDC_STNOPAGE), &dat->rcDisplay);
MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcDisplay, 2);
// Add an item to count in height
@@ -731,11 +882,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
tie.mask = TCIF_TEXT | TCIF_IMAGE;
tie.iImage = -1;
tie.pszText = _T("X");
- TabCtrl_InsertItem( GetDlgItem(hdlg, IDC_TAB), 0, &tie);
+ TabCtrl_InsertItem(GetDlgItem(hdlg, IDC_TAB), 0, &tie);
- GetWindowRect( GetDlgItem(hdlg, IDC_TAB), &dat->rcTab);
+ GetWindowRect(GetDlgItem(hdlg, IDC_TAB), &dat->rcTab);
MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcTab, 2);
- TabCtrl_AdjustRect( GetDlgItem(hdlg, IDC_TAB), FALSE, &dat->rcTab);
+ TabCtrl_AdjustRect(GetDlgItem(hdlg, IDC_TAB), FALSE, &dat->rcTab);
FillFilterCombo(hdlg, dat);
PostMessage(hdlg, DM_REBUILDPAGETREE, 0, 0);
@@ -743,182 +894,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
return TRUE;
case DM_REBUILDPAGETREE:
- {
- BOOL bRemoveFocusFromFilter = FALSE;
- HINSTANCE FilterInst = NULL;
-
- LPARAM oldSel = SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, CB_GETEDITSEL, 0, 0);
- GetDlgItemText(hdlg, IDC_KEYWORD_FILTER, dat->szFilterString, SIZEOF(dat->szFilterString));
-
- //if filter string is set to all modules then make the filter string empty (this will return all modules)
- if (_tcscmp(dat->szFilterString, TranslateT(ALL_MODULES_FILTER)) == 0) {
- dat->szFilterString[0] = 0;
- bRemoveFocusFromFilter = TRUE;
- }
- //if filter string is set to core modules replace it with the name of the executable (this will return all core modules)
- else if (_tcscmp(dat->szFilterString, TranslateT(CORE_MODULES_FILTER)) == 0) {
- //replace string with process name - that will show core settings
- TCHAR szFileName[300];
- GetModuleFileName(NULL, szFileName, SIZEOF(szFileName));
- TCHAR *pos = _tcsrchr(szFileName, _T('\\'));
- if (pos)
- pos++;
- else
- pos = szFileName;
-
- _tcsncpy(dat->szFilterString, pos, SIZEOF(dat->szFilterString));
- }
- else {
- int sel = SendMessage( GetDlgItem(hdlg, IDC_KEYWORD_FILTER), (UINT) CB_GETCURSEL, 0, 0);
- if (sel != -1) {
- HINSTANCE hinst = (HINSTANCE)SendMessage( GetDlgItem(hdlg, IDC_KEYWORD_FILTER), (UINT) CB_GETITEMDATA, sel , 0);
- TCHAR szFileName[300];
- GetModuleFileName(hinst, szFileName, SIZEOF(szFileName));
- TCHAR *pos = _tcsrchr(szFileName, _T('\\'));
- if (pos) pos++;
- else pos = szFileName;
- _tcsncpy(dat->szFilterString, pos, SIZEOF(dat->szFilterString));
- }
- }
-
- _tcslwr_locale(dat->szFilterString); //all strings are stored as lowercase ... make sure filter string is lowercase too
-
- SendMessage(hwndTree, WM_SETREDRAW, FALSE, 0);
-
- HWND oldWnd = NULL;
- HWND oldTab = NULL;
-
- opd = dat->getCurrent();
- if (opd != NULL) {
- oldWnd = opd->hwnd;
- if (opd->insideTab)
- oldTab = GetDlgItem(hdlg, IDC_TAB);
- }
-
- dat->hCurrentPage = NULL;
-
- TreeView_SelectItem(hwndTree, NULL);
- TreeView_DeleteAllItems(hwndTree);
-
- TVINSERTSTRUCT tvis;
- tvis.hParent = NULL;
- tvis.hInsertAfter = TVI_SORT;
- tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
- tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
- for (int i=0; i < dat->arOpd.getCount(); i++) {
- static TCHAR *fullTitle = NULL;
- mir_free(fullTitle); fullTitle = NULL;
- if ( !CheckPageShow(hdlg, dat, i))
- continue;
-
- opd = dat->arOpd[i];
- TCHAR* ptszGroup = TranslateTH(opd->hLangpack, opd->ptszGroup);
- TCHAR* ptszTitle = opd->getString(opd->ptszTitle);
- TCHAR* ptszTab = TranslateTH(opd->hLangpack, opd->ptszTab);
-
- tvis.hParent = NULL;
- if (FilterInst != NULL) {
- size_t sz = ptszGroup ? _tcslen(ptszGroup)+1:0;
- if (sz) sz+=3;
- sz += ptszTitle ? _tcslen(ptszTitle)+1 : 0;
- fullTitle = (TCHAR*)mir_alloc(sz*sizeof(TCHAR));
- mir_sntprintf(fullTitle, sz, (ptszGroup && ptszTitle)?_T("%s - %s"):_T("%s%s"),
- ptszGroup ? ptszGroup : _T(""),
- ptszTitle ? ptszTitle : _T(""));
- }
- TCHAR *useTitle = fullTitle ? fullTitle : ptszTitle;
- if (ptszGroup != NULL && FilterInst == NULL) {
- tvis.hParent = FindNamedTreeItemAtRoot(hwndTree, ptszGroup);
- if (tvis.hParent == NULL) {
- tvis.item.lParam = -1;
- tvis.item.pszText = ptszGroup;
- tvis.hParent = TreeView_InsertItem(hwndTree, &tvis);
- }
- }
- else {
- TVITEM tvi;
- tvi.hItem = FindNamedTreeItemAtRoot(hwndTree, useTitle);
- if (tvi.hItem != NULL) {
- if (i == dat->currentPage) dat->hCurrentPage = tvi.hItem;
- tvi.mask = TVIF_PARAM;
- TreeView_GetItem(hwndTree, &tvi);
- if (tvi.lParam == -1) {
- tvi.lParam = i;
- TreeView_SetItem(hwndTree, &tvi);
- continue;
- }
- }
- }
-
- if (ptszTab != NULL) {
- HTREEITEM hItem;
- if (tvis.hParent == NULL)
- hItem = FindNamedTreeItemAtRoot(hwndTree, useTitle);
- else
- hItem = FindNamedTreeItemAtChildren(hwndTree, tvis.hParent, useTitle);
- if (hItem != NULL) {
- if (i == dat->currentPage) {
- TVITEM tvi;
- tvi.hItem = hItem;
- tvi.mask = TVIF_PARAM;
- tvi.lParam = dat->currentPage;
- TreeView_SetItem(hwndTree, &tvi);
- dat->hCurrentPage = hItem;
- }
- continue;
- }
- }
-
- tvis.item.pszText = useTitle;
- tvis.item.lParam = i;
- opd->hTreeItem = TreeView_InsertItem(hwndTree, &tvis);
- if (i == dat->currentPage)
- dat->hCurrentPage = opd->hTreeItem;
-
- if (fullTitle) mir_free(fullTitle);
- fullTitle = NULL;
- }
-
- char str[128];
- TVITEMA tvi;
- tvi.mask = TVIF_TEXT | TVIF_STATE;
- tvi.pszText = str;
- tvi.cchTextMax = SIZEOF(str);
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while (tvi.hItem != NULL) {
- if ( SendMessageA(hwndTree, TVM_GETITEMA, 0, (LPARAM)&tvi)) {
- char buf[130];
- mir_snprintf(buf, SIZEOF(buf), "%s%s", OPTSTATE_PREFIX, str);
- if ( !db_get_b(NULL, "Options", buf, 1))
- TreeView_Expand(hwndTree, tvi.hItem, TVE_COLLAPSE);
- }
- tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- }
-
- if (dat->hCurrentPage == NULL) {
- dat->hCurrentPage = TreeView_GetRoot(hwndTree);
- dat->currentPage = -1;
- }
- TreeView_SelectItem(hwndTree, dat->hCurrentPage);
-
- if (oldWnd) {
- opd = dat->getCurrent();
- if (opd && oldWnd != opd->hwnd) {
- ShowWindow(oldWnd, SW_HIDE);
- if (oldTab && (opd == NULL || !opd->insideTab))
- ShowWindow(oldTab, SW_HIDE);
- }
- }
-
- if (dat->szFilterString[0] == 0) // Clear the keyword combo box
- SetWindowText( GetDlgItem(hdlg, IDC_KEYWORD_FILTER), _T(""));
- if ( !bRemoveFocusFromFilter)
- SetFocus( GetDlgItem(hdlg, IDC_KEYWORD_FILTER)); //set the focus back to the combo box
-
- SendDlgItemMessage(hdlg, IDC_KEYWORD_FILTER, CB_SETEDITSEL, 0, oldSel); //but don't select any of the text
-
- SendMessage(hwndTree, WM_SETREDRAW, TRUE, 0);
- }
+ RebuildPageTree(hdlg, dat);
break;
case HM_MODULELOAD:
@@ -930,7 +906,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
break;
case PSM_CHANGED:
- EnableWindow( GetDlgItem(hdlg, IDC_APPLY), TRUE);
+ EnableWindow(GetDlgItem(hdlg, IDC_APPLY), TRUE);
opd = dat->getCurrent();
if (opd)
@@ -943,10 +919,10 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
return TRUE;
case WM_NOTIFY:
- switch(wParam) {
+ switch (wParam) {
case IDC_TAB:
case IDC_PAGETREE:
- switch(((LPNMHDR)lParam)->code) {
+ switch (((LPNMHDR)lParam)->code) {
case TVN_ITEMEXPANDING:
SetWindowLongPtr(hdlg, DWLP_MSGRESULT, FALSE);
return TRUE;
@@ -969,7 +945,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
case TCN_SELCHANGE:
case TVN_SELCHANGED:
- ShowWindow( GetDlgItem(hdlg, IDC_STNOPAGE), SW_HIDE);
+ ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_HIDE);
opd = dat->getCurrent();
if (opd && opd->hwnd != NULL)
@@ -979,19 +955,19 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
TVITEM tvi;
tvi.hItem = dat->hCurrentPage = TreeView_GetSelection(hwndTree);
if (tvi.hItem == NULL) {
- ShowWindow( GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
+ ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
break;
}
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
TreeView_GetItem(hwndTree, &tvi);
dat->currentPage = tvi.lParam;
- ShowWindow( GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
+ ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE);
}
else {
TCITEM tie;
tie.mask = TCIF_PARAM;
- TabCtrl_GetItem( GetDlgItem(hdlg, IDC_TAB), TabCtrl_GetCurSel( GetDlgItem(hdlg, IDC_TAB)), &tie);
+ TabCtrl_GetItem(GetDlgItem(hdlg, IDC_TAB), TabCtrl_GetCurSel(GetDlgItem(hdlg, IDC_TAB)), &tie);
dat->currentPage = tie.lParam;
TVITEM tvi;
@@ -1003,7 +979,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
opd = dat->getCurrent();
if (opd == NULL) {
- ShowWindow( GetDlgItem(hdlg, IDC_STNOPAGE), SW_SHOW);
+ ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_SHOW);
break;
}
if (opd->hwnd == NULL) {
@@ -1024,11 +1000,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage);
if (opd->insideTab) {
- SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcTab.left+dat->rcTab.right-w)>>1, dat->rcTab.top, w, h, 0);
+ SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcTab.left + dat->rcTab.right - w) >> 1, dat->rcTab.top, w, h, 0);
ThemeDialogBackground(opd->hwnd, TRUE);
}
else {
- SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcDisplay.left+dat->rcDisplay.right-w)>>1, (dat->rcDisplay.top+dat->rcDisplay.bottom-h)>>1, w, h, 0);
+ SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcDisplay.left + dat->rcDisplay.right - w) >> 1, (dat->rcDisplay.top + dat->rcDisplay.bottom - h) >> 1, w, h, 0);
ThemeDialogBackground(opd->hwnd, FALSE);
}
}
@@ -1044,18 +1020,18 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
TCITEM tie;
tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
tie.iImage = -1;
- for (int i=0; i < dat->arOpd.getCount(); i++) {
- if ( !CheckPageShow(hdlg, dat, i))
+ for (int i = 0; i < dat->arOpd.getCount(); i++) {
+ if (!CheckPageShow(hdlg, dat, i))
continue;
OptionsPageData *p = dat->arOpd[i];
- if ( lstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup))
+ if (lstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup))
continue;
tie.pszText = TranslateTH(p->hLangpack, p->ptszTab);
tie.lParam = i;
TabCtrl_InsertItem(hwndTab, pages, &tie);
- if ( !lstrcmp(opd->ptszTab, p->ptszTab))
+ if (!lstrcmp(opd->ptszTab, p->ptszTab))
sel = pages;
pages++;
}
@@ -1093,12 +1069,12 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_KEYWORD_FILTER:
//add a timer - when the timer elapses filter the option pages
if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == CBN_EDITCHANGE))
- if ( !SetTimer(hdlg, FILTER_TIMEOUT_TIMER, 400, NULL))
- MessageBeep(MB_ICONSTOP);
+ if (!SetTimer(hdlg, FILTER_TIMEOUT_TIMER, 400, NULL))
+ MessageBeep(MB_ICONSTOP);
break;
case IDC_MODERN:
@@ -1114,7 +1090,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
pshn.hdr.idFrom = 0;
pshn.lParam = 0;
pshn.hdr.code = PSN_RESET;
- for (int i=0;i<dat->arOpd.getCount();i++) {
+ for (int i = 0; i < dat->arOpd.getCount(); i++) {
if (dat->arOpd[i]->hwnd == NULL || !dat->arOpd[i]->changed)
continue;
pshn.hdr.hwndFrom = dat->arOpd[i]->hwnd;
@@ -1126,12 +1102,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
case IDOK:
case IDC_APPLY:
- {
- if (LOWORD(wParam) == IDOK && GetParent(GetFocus()) == GetDlgItem(hdlg, IDC_KEYWORD_FILTER))
- return TRUE;
-
+ if (LOWORD(wParam) == IDOK && GetParent(GetFocus()) == GetDlgItem(hdlg, IDC_KEYWORD_FILTER))
+ return TRUE;
+ else {
PSHNOTIFY pshn;
- EnableWindow( GetDlgItem(hdlg, IDC_APPLY), FALSE);
+ EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE);
SetFocus(hwndTree);
opd = dat->getCurrent();
@@ -1145,7 +1120,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
}
pshn.hdr.code = PSN_APPLY;
- for (int i=0;i<dat->arOpd.getCount();i++) {
+ for (int i = 0; i < dat->arOpd.getCount(); i++) {
if (dat->arOpd[i]->hwnd == NULL || !dat->arOpd[i]->changed) continue;
dat->arOpd[i]->changed = 0;
pshn.hdr.hwndFrom = dat->arOpd[i]->hwnd;
@@ -1169,8 +1144,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
case WM_DESTROY:
if (FilterTimerId)
- KillTimer (hdlg, FilterTimerId);
- DestroyWindow (hFilterSearchWnd);
+ KillTimer(hdlg, FilterTimerId);
+ DestroyWindow(hFilterSearchWnd);
ClearFilterStrings();
dat->szFilterString[0] = 0;
@@ -1199,10 +1174,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
}
Utils_SaveWindowPosition(hdlg, NULL, "Options", "");
- {
- for (int i=0; i < dat->arOpd.getCount(); i++)
- FreeOptionsPageData(dat->arOpd[i]);
- }
+
+ for (int i = 0; i < dat->arOpd.getCount(); i++)
+ FreeOptionsPageData(dat->arOpd[i]);
DeleteObject(dat->hBoldFont);
delete dat;
@@ -1214,7 +1188,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
return FALSE;
}
-void OpenAccountOptions(PROTOACCOUNT* pa)
+void OpenAccountOptions(PROTOACCOUNT *pa)
{
if (pa->ppro == NULL)
return;
@@ -1224,7 +1198,7 @@ void OpenAccountOptions(PROTOACCOUNT* pa)
if (opi.pageCount == 0)
return;
- TCHAR tszTitle[ 100 ];
+ TCHAR tszTitle[100];
mir_sntprintf(tszTitle, SIZEOF(tszTitle), TranslateT("%s options"), pa->tszAccountName);
OPENOPTIONSDIALOG ood = { sizeof(ood) };
@@ -1232,7 +1206,7 @@ void OpenAccountOptions(PROTOACCOUNT* pa)
ood.pszPage = mir_t2a(pa->tszAccountName);
PROPSHEETHEADER psh = { sizeof(psh) };
- psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW;
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = NULL;
psh.nPages = opi.pageCount;
psh.pStartPage = (LPCTSTR)&ood;
@@ -1249,18 +1223,18 @@ static void OpenOptionsNow(int hLangpack, const char *pszGroup, const char *pszP
ShowWindow(hwndOptions, SW_RESTORE);
SetForegroundWindow(hwndOptions);
if (pszPage != NULL) {
- ptrT ptszPage( mir_a2t(pszPage));
+ ptrT ptszPage(mir_a2t(pszPage));
HTREEITEM hItem = NULL;
if (pszGroup != NULL) {
- ptrT ptszGroup( mir_a2t(pszGroup));
- hItem = FindNamedTreeItemAtRoot( GetDlgItem(hwndOptions, IDC_PAGETREE), TranslateTH(hLangpack, ptszGroup));
+ ptrT ptszGroup(mir_a2t(pszGroup));
+ hItem = FindNamedTreeItemAtRoot(GetDlgItem(hwndOptions, IDC_PAGETREE), TranslateTH(hLangpack, ptszGroup));
if (hItem != NULL)
- hItem = FindNamedTreeItemAtChildren( GetDlgItem(hwndOptions, IDC_PAGETREE), hItem, TranslateTH(hLangpack, ptszPage));
+ hItem = FindNamedTreeItemAtChildren(GetDlgItem(hwndOptions, IDC_PAGETREE), hItem, TranslateTH(hLangpack, ptszPage));
}
- else hItem = FindNamedTreeItemAtRoot( GetDlgItem(hwndOptions, IDC_PAGETREE), TranslateTH(hLangpack, ptszPage));
+ else hItem = FindNamedTreeItemAtRoot(GetDlgItem(hwndOptions, IDC_PAGETREE), TranslateTH(hLangpack, ptszPage));
if (hItem != NULL)
- TreeView_SelectItem( GetDlgItem(hwndOptions, IDC_PAGETREE), hItem);
+ TreeView_SelectItem(GetDlgItem(hwndOptions, IDC_PAGETREE), hItem);
}
}
else {
@@ -1341,7 +1315,7 @@ static INT_PTR AddOptionsPage(WPARAM wParam, LPARAM lParam)
if (odp->cbSize != sizeof(OPTIONSDIALOGPAGE) && odp->cbSize != OPTIONPAGE_OLD_SIZE)
return 1;
- opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1));
+ opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount + 1));
dst = opi->odp + opi->pageCount;
memset(dst, 0, sizeof(OPTIONSDIALOGPAGE));
memcpy(dst, odp, odp->cbSize);
@@ -1395,7 +1369,7 @@ static int OptModulesLoaded(WPARAM, LPARAM)
int ShutdownOptionsModule(WPARAM, LPARAM)
{
- if ( IsWindow(hwndOptions))
+ if (IsWindow(hwndOptions))
DestroyWindow(hwndOptions);
hwndOptions = NULL;
return 0;