From 3da123901eb43f8358daa98993fa2fead3852e56 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Sun, 12 Dec 2010 23:57:30 +0000 Subject: Fixes for ANSI version git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@581 4f64403b-2f21-0410-a795-97e2b3489a10 --- yapp/popwin.cpp | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'yapp/popwin.cpp') diff --git a/yapp/popwin.cpp b/yapp/popwin.cpp index 557a9cf..8957dd1 100644 --- a/yapp/popwin.cpp +++ b/yapp/popwin.cpp @@ -28,22 +28,23 @@ void trimW(wchar_t *str) { if(str[pos] == L'\t') str[pos] = L' '; } -void SetStartValues() { +void SetStartValues(void) +{ RECT wa_rect; - if(options.use_mim_monitor && MyMonitorFromRect && MyGetMonitorInfo) { + SystemParametersInfo(SPI_GETWORKAREA, 0, &wa_rect, 0); + if (options.use_mim_monitor && MyMonitorFromRect && MyGetMonitorInfo) + { RECT clr; - HMONITOR hMonitor; GetWindowRect((HWND)CallService(MS_CLUI_GETHWND, 0, 0), &clr); - hMonitor = MyMonitorFromRect(&clr, MONITOR_DEFAULTTONEAREST); - - MONITORINFO mi; - mi.cbSize = sizeof(mi); - MyGetMonitorInfo(hMonitor, &mi); - - wa_rect = mi.rcWork; - - } else - SystemParametersInfo(SPI_GETWORKAREA, 0, &wa_rect, 0); + HMONITOR hMonitor = MyMonitorFromRect(&clr, MONITOR_DEFAULTTONEAREST); + if (hMonitor) + { + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (MyGetMonitorInfo(hMonitor, &mi)) + wa_rect = mi.rcWork; + } + } if(options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT) pop_start_x = wa_rect.right - options.win_width - 1; @@ -490,7 +491,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); else SetTextColor(ps.hdc, colFirstLine); - DrawTextW(ps.hdc, pd->pwzTitle, (int)wcslen(pd->pwzTitle), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX); + TCHAR *title = mir_u2t(pd->pwzTitle); + DrawText(ps.hdc, title, (int)_tcslen(title), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX); + mir_free(title); // title underline RECT tur; @@ -501,8 +504,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa FillRect(ps.hdc, &tur, pwd->underlineBrush); // second line(s) - int len_second = (int)wcslen(pd->pwzText); - if(len_second) { + if(pd->pwzText[0]) { if(hFontSecondLine) SelectObject(ps.hdc, (HGDIOBJ)hFontSecondLine); if(!pwd->custom_col) SetTextColor(ps.hdc, colSecondLine); @@ -511,8 +513,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if(options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height <= pwd->tb_height && !pwd->have_av) GetClientRect(hwnd, &r); + TCHAR *text = mir_u2t(pd->pwzText); tr.left = r.left + options.padding + options.text_indent; tr.right = r.right - options.padding; tr.top = tr.bottom + options.padding; tr.bottom = r.bottom - options.padding; - DrawTextW(ps.hdc, pd->pwzText, len_second, &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); + DrawText(ps.hdc, text, (int)_tcslen(text), &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); + mir_free(text); } EndPaint(hwnd, &ps); @@ -638,8 +642,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa } // text height - int len_second = (int)wcslen(pd->pwzText); - if(len_second) { + if (pd->pwzText[0]) { RECT r; r.left = r.top = 0; r.right = options.win_width - 2 * options.padding - options.text_indent; @@ -651,8 +654,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa r.right -= pwd->time_width + options.padding; if(hFontSecondLine) SelectObject(hdc, (HGDIOBJ)hFontSecondLine); - DrawTextW(hdc, pd->pwzText, len_second, &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); + TCHAR *text = mir_u2t(pd->pwzText); + DrawText(hdc, text, (int)_tcslen(text), &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); pwd->text_height = r.bottom; + mir_free(text); } ReleaseDC(hwnd, hdc); -- cgit v1.2.3