From d6eee2018898f2442883a0aa77ad095b75572cfb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 27 Aug 2015 15:15:33 +0000 Subject: fix for 64-bit issues & warnings git-svn-id: http://svn.miranda-ng.org/main/trunk@15043 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/wbOSD/src/wbOSD.cpp | 243 ++++++++++++++++++++++---------------------- 1 file changed, 121 insertions(+), 122 deletions(-) (limited to 'plugins/wbOSD/src/wbOSD.cpp') diff --git a/plugins/wbOSD/src/wbOSD.cpp b/plugins/wbOSD/src/wbOSD.cpp index c7a7983a4d..0a9e341244 100644 --- a/plugins/wbOSD/src/wbOSD.cpp +++ b/plugins/wbOSD/src/wbOSD.cpp @@ -9,106 +9,106 @@ Distributed under GNU's GPL 2 or later #include "stdafx.h" -TCHAR szClassName[] = _T("wbOSD"); -const static osdmsg defstr={_T(""), 0, RGB(0, 0, 0), 0, 0}; +TCHAR szClassName[] = _T("wbOSD"); +const static osdmsg defstr = { _T(""), 0, RGB(0, 0, 0), 0, 0 }; int DrawMe(HWND hwnd, TCHAR *string, COLORREF color) { logmsg("DrawMe"); - if (!string) string=_T("bullshit"); - + if (!string) string = _T("bullshit"); + plgsettings plgs; loadDBSettings(&plgs); - HFONT fh=CreateFontIndirect(&(plgs.lf)); - + HFONT fh = CreateFontIndirect(&(plgs.lf)); + PAINTSTRUCT ps; - HDC hdc=BeginPaint(hwnd, &ps); + HDC hdc = BeginPaint(hwnd, &ps); SetBkMode(hdc, TRANSPARENT); RECT rect; GetClientRect(hwnd, &rect); - HBRUSH bkb=CreateSolidBrush(plgs.bkclr); + HBRUSH bkb = CreateSolidBrush(plgs.bkclr); FillRect(hdc, &rect, bkb); DeleteObject(bkb); - HGDIOBJ oo=SelectObject(hdc, fh); + HGDIOBJ oo = SelectObject(hdc, fh); - UINT talign=0; + UINT talign = 0; RECT rect2 = rect; - DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|DT_CALCRECT); + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | DT_CALCRECT); - if (plgs.align<=3) - rect.top=0; - else if (plgs.align<=6) - rect.top=(rect.bottom-rect2.bottom)/2; - else if (plgs.align<=9) - rect.top=rect.bottom-rect2.bottom; + if (plgs.align <= 3) + rect.top = 0; + else if (plgs.align <= 6) + rect.top = (rect.bottom - rect2.bottom) / 2; + else if (plgs.align <= 9) + rect.top = rect.bottom - rect2.bottom; - if (((plgs.align-1)%3)==0) - rect.left=0; - else if (((plgs.align-2)%3)==0) - rect.left=(rect.right-rect2.right)/2; - else if (((plgs.align-3)%3)==0) - rect.left=rect.right-rect2.right; + if (((plgs.align - 1) % 3) == 0) + rect.left = 0; + else if (((plgs.align - 2) % 3) == 0) + rect.left = (rect.right - rect2.right) / 2; + else if (((plgs.align - 3) % 3) == 0) + rect.left = rect.right - rect2.right; - rect.bottom=rect.top+rect2.bottom; - rect.right=rect.left+rect2.right; + rect.bottom = rect.top + rect2.bottom; + rect.right = rect.left + rect2.right; //draw shadow if (plgs.showShadow) { int sxo, syo; logmsg("DrawMe::showShadow"); - if (plgs.salign<=3) - syo=-plgs.distance; - else if (plgs.salign<=6) - syo=0; - else if (plgs.salign<=9) - syo=plgs.distance; + if (plgs.salign <= 3) + syo = -plgs.distance; + else if (plgs.salign <= 6) + syo = 0; + else if (plgs.salign <= 9) + syo = plgs.distance; else - syo=0; - - if (((plgs.salign-1)%3)==0) - sxo=-plgs.distance; - else if (((plgs.salign-2)%3)==0) - sxo=0; - else if (((plgs.salign-3)%3)==0) - sxo=plgs.distance; + syo = 0; + + if (((plgs.salign - 1) % 3) == 0) + sxo = -plgs.distance; + else if (((plgs.salign - 2) % 3) == 0) + sxo = 0; + else if (((plgs.salign - 3) % 3) == 0) + sxo = plgs.distance; else - sxo=0; + sxo = 0; SetTextColor(hdc, plgs.clr_shadow); - if (plgs.altShadow==0) { - rect2=rect; + if (plgs.altShadow == 0) { + rect2 = rect; OffsetRect(&rect, sxo, syo); - DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign); } else { rect2 = rect; rect2.left += plgs.distance; - DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign); rect2 = rect; rect2.left -= plgs.distance; - DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign); rect2 = rect; rect2.top -= plgs.distance; - DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign); rect2 = rect; rect2.top += plgs.distance; - DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK | talign); - OffsetRect(&rect, sxo/2, syo/2); + OffsetRect(&rect, sxo / 2, syo / 2); } } //draw text SetTextColor(hdc, color); DrawText(hdc, string, -1, &rect, DT_WORDBREAK); - + SelectObject(hdc, oo); DeleteObject(fh); EndPaint(hwnd, &ps); @@ -116,9 +116,9 @@ int DrawMe(HWND hwnd, TCHAR *string, COLORREF color) return 0; } -LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - osdmsg* ms; + osdmsg *ms; switch (message) { case WM_CREATE: @@ -133,10 +133,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_PAINT: logmsg("WindowProcedure::PAINT"); - ms=(osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + ms = (osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (ms) return DrawMe(hwnd, ms->text, ms->color); - + PAINTSTRUCT ps; BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); @@ -146,109 +146,109 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM logmsg("WindowProcedure::NCRBUTTONDOWN"); ms = (osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if ( ms ) { - if ( ms->callback) ms->callback(ms->param); - SendMessage(hwnd, WM_USER+3, 0, 0); + if (ms) { + if (ms->callback) ms->callback(ms->param); + SendMessage(hwnd, WM_USER + 3, 0, 0); } return 0; case WM_TIMER: logmsg("WindowProcedure::TIMER"); - SendMessage(hwnd, WM_USER+3, wParam, 0); + SendMessage(hwnd, WM_USER + 3, wParam, 0); return 0; - case WM_USER+1: //draw text ((char *)string, (int) timeout + case WM_USER + 1: //draw text ((char *)string, (int) timeout logmsg("WindowProcedure::USER+1"); - ms=(osdmsg*)mir_alloc(sizeof(osdmsg)); - ms->text = mir_tstrdup((TCHAR *)wParam ); - if ( lParam == 0 ) - lParam = db_get_dw( NULL,THIS_MODULE, "timeout", DEFAULT_TIMEOUT ); + ms = (osdmsg*)mir_alloc(sizeof(osdmsg)); + ms->text = mir_tstrdup((TCHAR *)wParam); + if (lParam == 0) + lParam = db_get_dw(NULL, THIS_MODULE, "timeout", DEFAULT_TIMEOUT); ms->timeout = lParam; ms->callback = 0; - ms->color = db_get_dw(NULL,THIS_MODULE, "clr_msg", DEFAULT_CLRMSG); + ms->color = db_get_dw(NULL, THIS_MODULE, "clr_msg", DEFAULT_CLRMSG); ms->param = 0; - SendMessage(hwnd, WM_USER+4, (WPARAM)ms, 0); + SendMessage(hwnd, WM_USER + 4, (WPARAM)ms, 0); mir_free(ms->text); mir_free(ms); return 0; - case WM_USER+2: //show + case WM_USER + 2: //show logmsg("WindowProcedure::USER+2"); - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_NOACTIVATE); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOACTIVATE); return 0; - case WM_USER+3: //hide - ms = ( osdmsg* )GetWindowLongPtr(hwnd, GWLP_USERDATA); + case WM_USER + 3: //hide + ms = (osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); logmsg("WindowProcedure::USER+3"); - if ( !ms ) + if (!ms) return 0; logmsg("WindowProcedure::USER+3/om"); - KillTimer(hwnd, (UINT)ms); + KillTimer(hwnd, (UINT_PTR)ms); mir_free(ms->text); mir_free(ms); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); ShowWindow(hwnd, SW_HIDE); return 0; - case WM_USER+4: + case WM_USER + 4: logmsg("WindowProcedure::USER+4"); ms = (osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if ( ms != 0 ) { + if (ms != 0) { logmsg("WindowProcedure::USER+4/old"); - KillTimer(hwnd, (UINT)ms); + KillTimer(hwnd, (UINT_PTR)ms); mir_free(ms->text); mir_free(ms); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); } - ms =(osdmsg*)mir_alloc(sizeof(osdmsg)); + ms = (osdmsg*)mir_alloc(sizeof(osdmsg)); memcpy(ms, (osdmsg*)wParam, sizeof(osdmsg)); - ms->text = mir_tstrdup( ms->text ); + ms->text = mir_tstrdup(ms->text); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)ms); - SetTimer(hwnd, (UINT)ms, (int)ms->timeout, 0); + SetTimer(hwnd, (UINT_PTR)ms, (UINT)ms->timeout, 0); InvalidateRect(hwnd, 0, TRUE); - SendMessage(hwnd, WM_USER+2, 0, 0); + SendMessage(hwnd, WM_USER + 2, 0, 0); return 0; case WM_NCHITTEST: { RECT rect; GetWindowRect(hwnd, &rect); - + logmsg("WindowProcedure::NCHITTEST"); - if (LOWORD(lParam)>=(rect.left+5) && LOWORD(lParam)<=(rect.right-5) && - HIWORD(lParam)>=(rect.top+5) && HIWORD(lParam)<=(rect.bottom-5)) + if (LOWORD(lParam) >= (rect.left + 5) && LOWORD(lParam) <= (rect.right - 5) && + HIWORD(lParam) >= (rect.top + 5) && HIWORD(lParam) <= (rect.bottom - 5)) return HTCAPTION; - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } - //here will be the doubleclick => open-message-window solution ;-) - //case WM_NCLBUTTONDBLCLK: - // CallService(MS_MSG_SENDMESSAGE, wparam,(LPARAM)&odp); - // return 0; + //here will be the doubleclick => open-message-window solution ;-) + //case WM_NCLBUTTONDBLCLK: + // CallService(MS_MSG_SENDMESSAGE, wparam,(LPARAM)&odp); + // return 0; default: - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } } INT_PTR OSDAnnounce(WPARAM wParam, LPARAM lParam) { logmsg("OSDAnnounce"); - return SendMessage(hwnd, WM_USER+1, wParam, lParam); + return SendMessage(g_hWnd, WM_USER + 1, wParam, lParam); } int pluginShutDown(WPARAM, LPARAM) { logmsg("pluginShutDown"); - if (hwnd) { + if (g_hWnd) { logmsg("pluginShutDown/hwnd"); - SendMessage(hwnd, WM_USER+3, 0, 0); - DestroyWindow(hwnd); - hwnd=0; + SendMessage(g_hWnd, WM_USER + 3, 0, 0); + DestroyWindow(g_hWnd); + g_hWnd = NULL; } return 0; } @@ -256,54 +256,53 @@ int pluginShutDown(WPARAM, LPARAM) int MainInit(WPARAM, LPARAM) { logmsg("MainInit"); - HookEvent(ME_OPT_INITIALISE,OptionsInit); - + HookEvent(ME_OPT_INITIALISE, OptionsInit); + WNDCLASSEX wincl; - wincl.hInstance = hI; - wincl.lpszClassName = szClassName; - wincl.lpfnWndProc = WindowProcedure; - wincl.style = CS_DBLCLKS; - wincl.cbSize = sizeof (WNDCLASSEX); - - wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); - wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); - wincl.hCursor = LoadCursor (NULL, IDC_ARROW); + wincl.hInstance = hI; + wincl.lpszClassName = szClassName; + wincl.lpfnWndProc = WindowProcedure; + wincl.style = CS_DBLCLKS; + wincl.cbSize = sizeof(WNDCLASSEX); + + wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + wincl.hCursor = LoadCursor(NULL, IDC_ARROW); wincl.lpszMenuName = NULL; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; - wincl.hbrBackground = 0; + wincl.hbrBackground = 0; - if ( !RegisterClassEx( &wincl )) + if (!RegisterClassEx(&wincl)) return 0; - hwnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TOOLWINDOW, szClassName, _T("WannaBeOSD"), + g_hWnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TOOLWINDOW, szClassName, _T("WannaBeOSD"), WS_POPUP, - db_get_dw(NULL,THIS_MODULE, "winxpos", DEFAULT_WINXPOS), - db_get_dw(NULL,THIS_MODULE, "winypos", DEFAULT_WINYPOS), - db_get_dw(NULL,THIS_MODULE, "winx", DEFAULT_WINX), - db_get_dw(NULL,THIS_MODULE, "winy", DEFAULT_WINY), + db_get_dw(NULL, THIS_MODULE, "winxpos", DEFAULT_WINXPOS), + db_get_dw(NULL, THIS_MODULE, "winypos", DEFAULT_WINYPOS), + db_get_dw(NULL, THIS_MODULE, "winx", DEFAULT_WINX), + db_get_dw(NULL, THIS_MODULE, "winy", DEFAULT_WINY), HWND_DESKTOP, NULL, hI, NULL); - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + SetWindowLongPtr(g_hWnd, GWLP_USERDATA, 0); + + SetLayeredWindowAttributes(g_hWnd, db_get_dw(NULL, THIS_MODULE, "bkclr", DEFAULT_BKCLR), db_get_b(NULL, THIS_MODULE, "alpha", DEFAULT_ALPHA), (db_get_b(NULL, THIS_MODULE, "transparent", DEFAULT_TRANPARENT) ? LWA_COLORKEY : 0) | LWA_ALPHA); - SetLayeredWindowAttributes(hwnd, db_get_dw(NULL,THIS_MODULE, "bkclr", DEFAULT_BKCLR), db_get_b(NULL,THIS_MODULE, "alpha", DEFAULT_ALPHA), (db_get_b(NULL,THIS_MODULE, "transparent", DEFAULT_TRANPARENT)?LWA_COLORKEY:0)|LWA_ALPHA); + hservosda = CreateServiceFunction("OSD/Announce", OSDAnnounce); + + HookEvent(ME_DB_EVENT_ADDED, HookedNewEvent); - hservosda=CreateServiceFunction("OSD/Announce", OSDAnnounce); - - hHookedNewEvent = HookEvent(ME_DB_EVENT_ADDED, HookedNewEvent); - // try to create ME_STATUSCHANGE_CONTACTSTATUSCHANGED event... I hope it fails when newstatusnotify or equal creates it before ;-) - - hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED,ContactStatusChanged); + + hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged); if (!hContactStatusChanged) { hHookContactStatusChanged = CreateHookableEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED); - hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ContactSettingChanged); + hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged); - hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED,ContactStatusChanged); + hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged); } - hProtoAck=HookEvent(ME_PROTO_ACK,ProtoAck); - - hpluginShutDown=HookEvent(ME_SYSTEM_SHUTDOWN,pluginShutDown); + hProtoAck = HookEvent(ME_PROTO_ACK, ProtoAck); + HookEvent(ME_SYSTEM_SHUTDOWN, pluginShutDown); return 0; } -- cgit v1.2.3