cinfownd.cpp
上传用户:kittypts
上传日期:2018-02-11
资源大小:241k
文件大小:5k
- /*****************************************************************************
- Windows Live Messenger Plugin Demo
- Copyright (C) 2008 Hern醤 Di Pietro
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- /*****************************************************************************/
- #include "wlmplugin.h"
- #include "clrzwind.h"
- #include "cinfownd.h"
- static WNDPROC pfnColorizedWndProc;
- static void DrawTextStrings(HDC hdc)
- {
- LOGFONT lf, lfb, lftitle;
- HFONT hFont, hFontBold, hFontTitle;
- ZeroMemory(&lf, sizeof(lf));
- lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- lf.lfWeight = 0;
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
- lf.lfQuality = CLEARTYPE_QUALITY;
- lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
- CopyMemory (&lfb, &lf, sizeof(lf));
- CopyMemory (&lftitle, &lf, sizeof(lf));
- lfb.lfWeight = FW_BOLD;
- lfb.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- lftitle.lfWeight = FW_BOLD;
- lftitle.lfHeight = -MulDiv(11, GetDeviceCaps(hdc, LOGPIXELSY), 72);
- hFont = CreateFontIndirect (&lf);
- hFontBold = CreateFontIndirect (&lfb);
- hFontTitle = CreateFontIndirect (&lftitle);
-
- SetBkMode(hdc, TRANSPARENT);
- SelectObject(hdc, hFontTitle);
- SetTextColor(hdc, RGB(255,255,255));
- TextOut(hdc, 10, 10, wszHeader, wcslen(wszHeader));
- SetTextColor(hdc, 0);
- TextOut(hdc, 10, 45, wszSignInNameHdr, wcslen(wszSignInNameHdr));
- SelectObject(hdc, hFont);
- TextOut(hdc, 10, 60, g_wlmContactInfoWindow.wszContactID,
- wcslen(g_wlmContactInfoWindow.wszContactID));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, 10, 80, wszFdlyNameHdr, wcslen(wszFdlyNameHdr));
- SelectObject(hdc, hFont);
- TextOut(hdc, 10, 95, g_wlmContactInfoWindow.wszFriendlyName,
- wcslen(g_wlmContactInfoWindow.wszFriendlyName));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, 10, 115, wszStatusHeader, wcslen(wszStatusHeader));
- int i = 0;
- while (i < NUM_STATUS_STRINGS_ELEM && statStrings[i].msStat != g_wlmContactInfoWindow.msStatus) i++;
- SelectObject(hdc, hFont);
- TextOut(hdc, 10, 130, statStrings[i].wszStatus, wcslen(statStrings[i].wszStatus));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, CIW_DEFAULT_WIDTH / 2, 115, wszBlockedHeader, wcslen(wszBlockedHeader));
- SelectObject(hdc, hFont);
- TextOut(hdc, CIW_DEFAULT_WIDTH / 2, 130, (g_wlmContactInfoWindow.fBlocked ? L"Yes" : L"No"),
- wcslen(g_wlmContactInfoWindow.fBlocked ? L"Yes" : L"No"));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, (CIW_DEFAULT_WIDTH / 2) + 50, 115, wszCanPageHeader, wcslen(wszCanPageHeader));
- SelectObject(hdc, hFont);
- TextOut(hdc, (CIW_DEFAULT_WIDTH / 2) + 50, 130, (g_wlmContactInfoWindow.fCanPage ? L"Yes" : L"No"),
- wcslen(g_wlmContactInfoWindow.fCanPage ? L"Yes" : L"No"));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, 10, 150, wszPhoneHomeHeader, wcslen(wszPhoneHomeHeader));
- SelectObject(hdc, hFont);
- if (g_wlmContactInfoWindow.wszHomePhone)
- TextOut(hdc, 10, 165, g_wlmContactInfoWindow.wszHomePhone, wcslen(g_wlmContactInfoWindow.wszHomePhone));
- else
- TextOut(hdc, 10, 165, L"N/A", wcslen(L"N/A"));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, 10, 180, wszPhoneMobileHeader, wcslen(wszPhoneMobileHeader));
- SelectObject(hdc, hFont);
- if (g_wlmContactInfoWindow.wszMobilePhone)
- TextOut(hdc, 10, 195, g_wlmContactInfoWindow.wszMobilePhone, wcslen(g_wlmContactInfoWindow.wszMobilePhone));
- else
- TextOut(hdc, 10, 195, L"N/A", wcslen(L"N/A"));
- SelectObject(hdc, hFontBold);
- TextOut(hdc, 10, 215, wszPhoneWorkHeader, wcslen(wszPhoneWorkHeader));
- SelectObject(hdc, hFont);
- if (g_wlmContactInfoWindow.wszWorkPhone)
- TextOut(hdc, 10, 230, g_wlmContactInfoWindow.wszWorkPhone, wcslen(g_wlmContactInfoWindow.wszWorkPhone));
- else
- TextOut(hdc, 10, 230, L"N/A", wcslen(L"N/A"));
- DeleteObject(hFont);
- DeleteObject(hFontBold);
- DeleteObject(hFontTitle);
- }
- LRESULT ContactInfoWndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
- {
- PAINTSTRUCT ps;
- HDC hdc;
- switch (msg)
- {
- case WM_PAINT:
- hdc = BeginPaint(hwnd, &ps);
- DrawTextStrings(hdc);
- EndPaint(hwnd, &ps);
- return 0L;
- case WM_NCHITTEST: // prevent dragging
- return 0L;
- }
- return CallWindowProc(pfnColorizedWndProc, hwnd,msg,wparam,lparam);
- }
- void CreateContactInfoWnd(HWND* pHWnd)
- {
- // Create the contact info window with the colorized window class
- *pHWnd = CreateWindowEx(WS_EX_NOACTIVATE, wszColorizedWndClass, NULL, WS_POPUP,
- 0, 0, CIW_DEFAULT_WIDTH, CIW_DEFAULT_HEIGHT,
- NULL, NULL, hDllInst, NULL );
- // window subclassing
- if (*pHWnd)
- {
- pfnColorizedWndProc = (WNDPROC) GetWindowLongPtr(*pHWnd, GWLP_WNDPROC);
- SetWindowLongPtr(*pHWnd, GWLP_WNDPROC, (LONG_PTR)ContactInfoWndProc );
- }
-
- }