diff options
author | George Hazan <george.hazan@gmail.com> | 2015-02-25 17:20:21 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-02-25 17:20:21 +0000 |
commit | 49b90802d624e53129e51dfce1d78d2ef28ed68c (patch) | |
tree | c7797cb8ddf1ac8f8501413f49dd460b96153b9d /src | |
parent | 8eb1d5e8c3dc27cdb64f9ca9b4a9f255dbc706ab (diff) |
MHeaderBar not to suppress window's caption drawing
git-svn-id: http://svn.miranda-ng.org/main/trunk@12267 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/miranda.cpp | 3 | ||||
-rw-r--r-- | src/modules/options/headerbar.cpp | 112 | ||||
-rw-r--r-- | src/modules/options/options.cpp | 140 |
3 files changed, 111 insertions, 144 deletions
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index e4e56c0f15..c2f92d7e9d 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -217,8 +217,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) getBufferedPaintBits = (pfnGetBufferedPaintBits)GetProcAddress(hThemeAPI, "GetBufferedPaintBits");
}
}
- else
- hDwmApi = hThemeAPI = 0;
+ else hDwmApi = hThemeAPI = 0;
if (bufferedPaintInit)
bufferedPaintInit();
diff --git a/src/modules/options/headerbar.cpp b/src/modules/options/headerbar.cpp index 74acffc664..fe0c0bd2da 100644 --- a/src/modules/options/headerbar.cpp +++ b/src/modules/options/headerbar.cpp @@ -50,35 +50,32 @@ struct MHeaderbarCtrl : public MZeroedObject MHeaderbarCtrl() {}
~MHeaderbarCtrl() { mir_free(controlsToRedraw); }
- HWND hwnd;
+ HWND hwnd;
// UI info
- RECT rc;
- int width, height;
- HICON hIcon;
+ RECT rc;
+ int width, height;
+ HICON hIcon;
// control colors
- RGBQUAD rgbBkgTop, rgbBkgBottom;
- COLORREF clText;
+ RGBQUAD rgbBkgTop, rgbBkgBottom;
+ COLORREF clText;
- int nControlsToRedraw;
- HWND *controlsToRedraw;
+ int nControlsToRedraw;
+ HWND *controlsToRedraw;
// fonts
- HFONT hFont;
+ HFONT hFont;
};
int LoadHeaderbarModule()
{
- WNDCLASSEX wc;
-
- memset(&wc, 0, sizeof(wc));
+ WNDCLASSEX wc = { 0 };
wc.cbSize = sizeof(wc);
- wc.lpszClassName = _T("MHeaderbarCtrl"); //MIRANDAHEADERBARCLASS;
+ wc.lpszClassName = _T("MHeaderbarCtrl");
wc.lpfnWndProc = MHeaderbarWndProc;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.cbWndExtra = sizeof(MHeaderbarCtrl*);
- wc.hbrBackground = 0; //GetStockObject(WHITE_BRUSH);
wc.style = CS_GLOBALCLASS|CS_SAVEBITS;
RegisterClassEx(&wc);
return 0;
@@ -86,22 +83,20 @@ int LoadHeaderbarModule() static void MHeaderbar_SetupColors(MHeaderbarCtrl *dat)
{
- COLORREF cl;
-
- cl = GetSysColor(COLOR_WINDOW);
- dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95;
- dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95;
- dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95;
-
- dat->clText = GetSysColor(COLOR_WINDOWTEXT);
-
- if (!dat->hFont) dat->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ COLORREF cl = GetSysColor(COLOR_WINDOW);
+ dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95;
+ dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95;
+ dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95;
+
+ dat->clText = GetSysColor(COLOR_WINDOWTEXT);
+ if (!dat->hFont)
+ dat->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
}
static void MHeaderbar_FillRect(HDC hdc, int x, int y, int width, int height, COLORREF cl)
{
- int oldMode = SetBkMode(hdc, OPAQUE);
- COLORREF oldColor = SetBkColor(hdc, cl);
+ int oldMode = SetBkMode(hdc, OPAQUE);
+ COLORREF oldColor = SetBkColor(hdc, cl);
RECT rc; SetRect(&rc, x, y, x+width, y+height);
ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, 0);
@@ -112,16 +107,15 @@ static void MHeaderbar_FillRect(HDC hdc, int x, int y, int width, int height, CO static void MHeaderbar_DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1)
{
- int oldMode = SetBkMode(hdc, OPAQUE);
- COLORREF oldColor = SetBkColor(hdc, 0);
+ int oldMode = SetBkMode(hdc, OPAQUE);
+ COLORREF oldColor = SetBkColor(hdc, 0);
- RECT rc; SetRect(&rc, x, 0, x+width, 0);
- for (int i = y+height; --i >= y;)
- {
+ RECT rc; SetRect(&rc, x, 0, x + width, 0);
+ for (int i = y + height; --i >= y;) {
COLORREF color = RGB(
- ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height,
- ((height-i-1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height,
- ((height-i-1)*rgb0->rgbBlue + i*rgb1->rgbBlue) / height);
+ ((height - i - 1)*rgb0->rgbRed + i*rgb1->rgbRed) / height,
+ ((height - i - 1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height,
+ ((height - i - 1)*rgb0->rgbBlue + i*rgb1->rgbBlue) / height);
rc.top = rc.bottom = i;
++rc.bottom;
SetBkColor(hdc, color);
@@ -143,7 +137,8 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, GetWindowText(hwndDlg, szTitle, titleLength);
TCHAR *szSubTitle = _tcschr(szTitle, _T('\n'));
- if (szSubTitle) *szSubTitle++=0;
+ if (szSubTitle)
+ *szSubTitle++ = 0;
HDC hdc = BeginPaint(hwndDlg, &ps);
HDC tempDC = CreateCompatibleDC(hdc);
@@ -160,18 +155,14 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
if (IsAeroMode()) {
- RECT temprc;
- temprc.left = 0;
- temprc.right = mit->width;
- temprc.top = 0;
- temprc.bottom = mit->width;
+ RECT temprc = { 0, 0, mit->width, mit->width };
FillRect(tempDC, &temprc, (HBRUSH)GetStockObject(BLACK_BRUSH));
- MARGINS margins = {0, 0, mit->height, 0};
+ MARGINS margins = { 0, 0, mit->height, 0 };
dwmExtendFrameIntoClientArea(GetParent(hwndDlg), &margins);
WTA_OPTIONS opts;
- opts.dwFlags = opts.dwMask = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON;
+ opts.dwFlags = opts.dwMask = WTNCA_NOSYSMENU | WTNCA_NODRAWICON;
setWindowThemeAttribute(GetParent(hwndDlg), WTA_NONCLIENT, &opts, sizeof(opts));
}
else {
@@ -206,12 +197,12 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, textRect.left = 50;
textRect.right = mit->width;
textRect.top = 2 + iTopSpace;
- textRect.bottom = GetSystemMetrics(SM_CYICON)-2 + iTopSpace;
+ textRect.bottom = GetSystemMetrics(SM_CYICON) - 2 + iTopSpace;
if (IsAeroMode()) {
- DTTOPTS dto = {0};
+ DTTOPTS dto = { 0 };
dto.dwSize = sizeof(dto);
- dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE;
+ dto.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE;
dto.iGlowSize = 10;
HANDLE hTheme = OpenThemeData(hwndDlg, L"Window");
@@ -219,7 +210,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, hOldFont = (HFONT)SelectObject(tempDC, hFntBold);
wchar_t *szTitleW = mir_t2u(szTitle);
- drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szTitleW, -1, DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS, &textRect, &dto);
+ drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szTitleW, -1, DT_TOP | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS, &textRect, &dto);
mir_free(szTitleW);
if (szSubTitle) {
@@ -227,7 +218,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, SelectObject(tempDC, hFont);
wchar_t *szSubTitleW = mir_t2u(szSubTitle);
- drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szSubTitleW, -1, DT_BOTTOM|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS, &textRect, &dto);
+ drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szSubTitleW, -1, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS, &textRect, &dto);
mir_free(szSubTitleW);
}
CloseThemeData(hTheme);
@@ -235,12 +226,12 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, else {
textRect.left = 50;
hOldFont = (HFONT)SelectObject(tempDC, hFntBold);
- DrawText(tempDC, szTitle, -1, &textRect, DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS);
+ DrawText(tempDC, szTitle, -1, &textRect, DT_TOP | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
if (szSubTitle) {
textRect.left = 66;
SelectObject(tempDC, hFont);
- DrawText(tempDC, szSubTitle, -1, &textRect, DT_BOTTOM|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS);
+ DrawText(tempDC, szSubTitle, -1, &textRect, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
}
}
@@ -249,8 +240,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, mir_free(szTitle);
//Copy to output
- if (mit->nControlsToRedraw)
- {
+ if (mit->nControlsToRedraw) {
RECT temprc;
temprc.left = 0;
temprc.right = mit->width;
@@ -258,8 +248,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, temprc.bottom = mit->width;
HRGN hRgn = CreateRectRgnIndirect(&temprc);
- for (int i=0; i < mit->nControlsToRedraw; i++)
- {
+ for (int i = 0; i < mit->nControlsToRedraw; i++) {
GetWindowRect(mit->controlsToRedraw[i], &temprc);
MapWindowPoints(NULL, hwndDlg, (LPPOINT)&temprc, 2);
HRGN hRgnTmp = CreateRectRgnIndirect(&temprc);
@@ -276,7 +265,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, SelectObject(tempDC, hOldBmp);
DeleteObject(hBmp);
- SelectObject(tempDC,hOldFont);
+ SelectObject(tempDC, hOldFont);
DeleteDC(tempDC);
EndPaint(hwndDlg, &ps);
@@ -287,7 +276,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
MHeaderbarCtrl* itc = (MHeaderbarCtrl *)GetWindowLongPtr(hwndDlg, 0);
- switch(msg) {
+ switch (msg) {
case WM_NCCREATE:
itc = new MHeaderbarCtrl; //(MHeaderbarCtrl*)mir_alloc(sizeof(MHeaderbarCtrl));
@@ -299,15 +288,12 @@ static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam RECT rcWnd; GetWindowRect(hwndDlg, &rcWnd);
itc->controlsToRedraw = 0;
itc->nControlsToRedraw = 0;
- for (HWND hChild = FindWindowEx(hParent, NULL, NULL, NULL); hChild; hChild = FindWindowEx(hParent, hChild, NULL, NULL))
- {
- if (hChild != hwndDlg)
- {
+ for (HWND hChild = FindWindowEx(hParent, NULL, NULL, NULL); hChild; hChild = FindWindowEx(hParent, hChild, NULL, NULL)) {
+ if (hChild != hwndDlg) {
RECT rcChild; GetWindowRect(hChild, &rcChild);
RECT rc;
IntersectRect(&rc, &rcChild, &rcWnd);
- if (!IsRectEmpty(&rc))
- {
+ if (!IsRectEmpty(&rc)) {
++itc->nControlsToRedraw;
itc->controlsToRedraw = (HWND *)mir_realloc(itc->controlsToRedraw, sizeof(HWND) * itc->nControlsToRedraw);
itc->controlsToRedraw[itc->nControlsToRedraw - 1] = hChild;
@@ -324,8 +310,8 @@ static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam case WM_SIZE:
GetClientRect(hwndDlg, &itc->rc);
- itc->width = itc->rc.right-itc->rc.left;
- itc->height = itc->rc.bottom-itc->rc.top;
+ itc->width = itc->rc.right - itc->rc.left;
+ itc->height = itc->rc.bottom - itc->rc.top;
return TRUE;
case WM_THEMECHANGED:
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index aa6b7cc3a1..73b05346c8 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h"
#include "filter.h"
-#define OPENOPTIONSDIALOG_OLD_SIZE 12
-
#define FILTER_TIMEOUT_TIMER 10012
#define ALL_MODULES_FILTER LPGEN("<all modules>")
@@ -222,24 +220,24 @@ PageHash GetPluginPageHash(const OptionsPageData *page) static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWndParent, const OptionsPageData *page)
{
- TCHAR pluginName[MAX_PATH];
HWND hWnd = 0;
if (enableKeywordFiltering) {
if (current)
hWnd = page->hwnd;
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
+ ShowWindow(hWnd, SW_HIDE); // make sure it's hidden
}
}
- DWORD key = GetPluginPageHash(page); //get the plugin page hash
+ DWORD key = GetPluginPageHash(page); // get the plugin page hash
+ TCHAR pluginName[MAX_PATH];
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
+ DestroyWindow(hWnd); // destroy the page, we're done with it
}
static int MatchesFilter(const OptionsPageData *page, TCHAR *szFilterString)
@@ -257,13 +255,9 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA RECT rc;
GetClientRect(hWnd, &rc);
- HDC hdc;
- PAINTSTRUCT paint;
- if (message == WM_PAINT)
- hdc = BeginPaint(hWnd, &paint);
- else
- hdc = (HDC)wParam;
+ PAINTSTRUCT paint;
+ HDC hdc = (message == WM_PAINT) ? BeginPaint(hWnd, &paint) : (HDC)wParam;
TCHAR buf[255];
if (bSearchState == 1 && FilterLoadProgress < 100 && FilterLoadProgress > 0)
@@ -271,7 +265,7 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA else
mir_sntprintf(buf, SIZEOF(buf), TranslateT("Search"));
- BOOL bDrawnByTheme = FALSE;
+ bool bDrawnByTheme = false;
int oldMode = SetBkMode(hdc, TRANSPARENT);
@@ -297,7 +291,7 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA SelectObject(hdc, oldFont);
CloseThemeData(hTheme);
- bDrawnByTheme = TRUE;
+ bDrawnByTheme = true;
}
SetBkMode(hdc, oldMode);
@@ -319,13 +313,12 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA return 0;
}
-static BOOL CheckPageShow(HWND hdlg, OptionsDlgData* dat, int i)
+static bool CheckPageShow(HWND hdlg, OptionsDlgData *dat, int i)
{
- OptionsPageData* opd = dat->arOpd[i];
-
+ OptionsPageData *opd = dat->arOpd[i];
if (dat->szFilterString && dat->szFilterString[0] && !MatchesFilter(opd, dat->szFilterString))
- return FALSE;
- return TRUE;
+ return false;
+ return true;
}
static BOOL IsAeroMode()
@@ -357,11 +350,12 @@ 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 LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+static void AeroPaintControl(HWND hwnd, HDC hdc, UINT msg, LPARAM lpFlags)
{
- HBITMAP hBmp, hOldBmp;
- RECT rc; GetClientRect(hwnd, &rc);
- BYTE *pBits;
+ RECT rc;
+ GetClientRect(hwnd, &rc);
HDC tempDC = CreateCompatibleDC(hdc);
@@ -372,21 +366,23 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
- hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, (void **)&pBits, NULL, 0);
- hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
+ BYTE *pBits;
+ HBITMAP hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, (void **)&pBits, NULL, 0);
+ HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
- //paint
+ // paint
SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)TRUE);
- mir_callNextSubclass(hwnd, OldWndProc, msg, (WPARAM)tempDC, lpFlags);
+ mir_callNextSubclass(hwnd, AeroPaintSubclassProc, msg, (WPARAM)tempDC, lpFlags);
SetPropA(hwnd, "Miranda.AeroRender.Active", (HANDLE)FALSE);
// Fix alpha channel
GdiFlush();
for (int i = 0; i < rc.right*rc.bottom; i++, pBits += 4)
- if (!pBits[3]) pBits[3] = 255;
+ if (!pBits[3])
+ pBits[3] = 255;
- //Copy to output
+ // Copy to output
BitBlt(hdc, 0, 0, rc.right, rc.bottom, tempDC, 0, 0, SRCCOPY);
SelectObject(tempDC, hOldBmp);
DeleteObject(hBmp);
@@ -406,21 +402,19 @@ static LRESULT CALLBACK AeroPaintSubclassProc(HWND hwnd, UINT msg, WPARAM wParam case WM_PRINT:
case WM_PRINTCLIENT:
- AeroPaintControl(hwnd, (HDC)wParam, AeroPaintSubclassProc, msg, lParam);
- return TRUE;
-
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- AeroPaintControl(hwnd, hdc, AeroPaintSubclassProc);
- EndPaint(hwnd, &ps);
- }
+ AeroPaintControl(hwnd, (HDC)wParam, msg, lParam);
return TRUE;
case WM_DESTROY:
RemovePropA(hwnd, "Miranda.AeroRender.Active");
break;
+
+ case WM_PAINT:
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hwnd, &ps);
+ AeroPaintControl(hwnd, hdc, WM_PRINT, PRF_CLIENT | PRF_NONCLIENT);
+ EndPaint(hwnd, &ps);
+ return TRUE;
}
return mir_callNextSubclass(hwnd, AeroPaintSubclassProc, msg, wParam, lParam);
}
@@ -467,7 +461,7 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat) 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++) {
FindFilterStrings(FALSE, FALSE, hDlg, dat->arOpd[i]); // only modules name (fast enougth)
@@ -484,7 +478,9 @@ static void FillFilterCombo(HWND hDlg, OptionsDlgData* dat) KnownInstances[countKnownInst] = inst;
countKnownInst++;
- GetModuleFileName(inst, tszModuleName, MAX_PATH);
+
+ TCHAR tszModuleName[MAX_PATH];
+ GetModuleFileName(inst, tszModuleName, SIZEOF(tszModuleName));
TCHAR *dllName = mir_a2t(GetPluginNameByInstance(inst));
if (!dllName) dllName = mir_tstrdup(_tcsrchr(tszModuleName, _T('\\')));
@@ -762,7 +758,7 @@ static void LoadOptionsModule(HWND hdlg, OptionsDlgData *dat, HINSTANCE hInst) return;
for (int i = 0; i < opi.pageCount; i++) {
- OptionsPageData* opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
+ OptionsPageData *opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData));
if (LoadOptionsPage(&opi.odp[i], opd))
dat->arOpd.insert(opd);
else
@@ -778,7 +774,7 @@ static void UnloadOptionsModule(HWND hdlg, OptionsDlgData *dat, HINSTANCE hInst) bool bToRebuildTree = false;
for (int i = dat->arOpd.getCount() - 1; i >= 0; i--) {
- OptionsPageData* opd = dat->arOpd[i];
+ OptionsPageData *opd = dat->arOpd[i];
if (opd->hInst != hInst)
continue;
@@ -814,10 +810,14 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L if (!ServiceExists(MS_MODERNOPT_SHOW))
ShowWindow(GetDlgItem(hdlg, IDC_MODERN), FALSE);
- {
- PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam;
- OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)psh->pStartPage;
+ dat = new OptionsDlgData;
+ SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)dat);
+
+ Utils_RestoreWindowPositionNoSize(hdlg, NULL, "Options", "");
+ Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_OPTIONS);
+ EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE);
+ {
COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
GetComboBoxInfo(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi);
@@ -828,11 +828,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L mir_subclassWindow(cbi.hwndItem, AeroPaintSubclassProc);
}
- Utils_RestoreWindowPositionNoSize(hdlg, NULL, "Options", "");
- Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_OPTIONS);
- EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE);
- dat = new OptionsDlgData;
- SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)dat);
+ PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam;
SetWindowText(hdlg, psh->pszCaption);
LOGFONT lf;
@@ -846,6 +842,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L dat->currentPage = -1;
ptrT lastPage, lastGroup, lastTab;
+ OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)psh->pStartPage;
if (ood->pszPage == NULL) {
lastPage = db_get_tsa(NULL, "Options", "LastPage");
@@ -1043,10 +1040,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L ShowWindow(hwndTab, opd->insideTab ? SW_SHOW : SW_HIDE);
}
- if (opd->insideTab)
- ThemeDialogBackground(opd->hwnd, TRUE);
- else
- ThemeDialogBackground(opd->hwnd, FALSE);
+ ThemeDialogBackground(opd->hwnd, opd->insideTab);
}
ShowWindow(opd->hwnd, SW_SHOW);
@@ -1075,7 +1069,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_KEYWORD_FILTER:
- //add a timer - when the timer elapses filter the option pages
+ // 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);
@@ -1246,17 +1240,19 @@ static void OpenOptionsNow(int hLangpack, const char *pszGroup, const char *pszP if (opi.pageCount == 0)
return;
- OPENOPTIONSDIALOG ood = { sizeof(ood) };
+ OPENOPTIONSDIALOG ood = { 0 };
+ ood.cbSize = sizeof(ood);
ood.pszGroup = pszGroup;
ood.pszPage = pszPage;
ood.pszTab = pszTab;
- PROPSHEETHEADER psh = { sizeof(psh) };
+ PROPSHEETHEADER psh = { 0 };
+ psh.dwSize = sizeof(psh);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.nPages = opi.pageCount;
- psh.pStartPage = (LPCTSTR)&ood; //more structure misuse
+ psh.pStartPage = (LPCTSTR)&ood; // more structure misuse
psh.pszCaption = TranslateT("Miranda NG options");
- psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell
+ psh.ppsp = (PROPSHEETPAGE*)opi.odp; // blatent misuse of the structure, but what the hell
hwndOptions = CreateDialogParam(hInst,
MAKEINTRESOURCE(bSinglePage ? IDD_OPTIONSPAGE : IDD_OPTIONS),
@@ -1269,34 +1265,20 @@ static void OpenOptionsNow(int hLangpack, const char *pszGroup, const char *pszP static INT_PTR OpenOptions(WPARAM wParam, LPARAM lParam)
{
OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)lParam;
- if (ood == NULL)
- return 1;
-
- int hLangpack = (int)wParam;
- if (ood->cbSize == OPENOPTIONSDIALOG_OLD_SIZE)
- OpenOptionsNow(hLangpack, ood->pszGroup, ood->pszPage, NULL);
- else if (ood->cbSize == sizeof(OPENOPTIONSDIALOG))
- OpenOptionsNow(hLangpack, ood->pszGroup, ood->pszPage, ood->pszTab);
- else
+ if (ood == NULL || ood->cbSize != sizeof(OPENOPTIONSDIALOG))
return 1;
-
+
+ OpenOptionsNow((int)wParam, ood->pszGroup, ood->pszPage, ood->pszTab);
return 0;
}
static INT_PTR OpenOptionsPage(WPARAM wParam, LPARAM lParam)
{
OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)lParam;
- if (ood == NULL)
- return 1;
-
- int hLangpack = (int)wParam;
- if (ood->cbSize == OPENOPTIONSDIALOG_OLD_SIZE)
- OpenOptionsNow(hLangpack, ood->pszGroup, ood->pszPage, NULL, true);
- else if (ood->cbSize == sizeof(OPENOPTIONSDIALOG))
- OpenOptionsNow(hLangpack, ood->pszGroup, ood->pszPage, ood->pszTab, true);
- else
+ if (ood == NULL || ood->cbSize != sizeof(OPENOPTIONSDIALOG))
return 1;
+ OpenOptionsNow((int)wParam, ood->pszGroup, ood->pszPage, ood->pszTab, true);
return (INT_PTR)hwndOptions;
}
|