cinfownd.cpp
上传用户:kittypts
上传日期:2018-02-11
资源大小:241k
文件大小:5k
源码类别:

PlugIns编程

开发平台:

Visual C++

  1. /*****************************************************************************
  2. Windows Live Messenger Plugin Demo
  3. Copyright (C) 2008  Hern醤 Di Pietro
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. /*****************************************************************************/
  15. #include "wlmplugin.h"
  16. #include "clrzwind.h"
  17. #include "cinfownd.h"
  18. static WNDPROC pfnColorizedWndProc;
  19. static void DrawTextStrings(HDC hdc)
  20. {
  21. LOGFONT lf, lfb, lftitle;
  22. HFONT hFont, hFontBold, hFontTitle;
  23. ZeroMemory(&lf, sizeof(lf));
  24. lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
  25. lf.lfWeight = 0;
  26. lf.lfCharSet = DEFAULT_CHARSET;
  27. lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
  28. lf.lfQuality = CLEARTYPE_QUALITY; 
  29. lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
  30. CopyMemory (&lfb, &lf, sizeof(lf));
  31. CopyMemory (&lftitle, &lf, sizeof(lf));
  32. lfb.lfWeight = FW_BOLD;
  33. lfb.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72);
  34. lftitle.lfWeight = FW_BOLD;
  35. lftitle.lfHeight = -MulDiv(11, GetDeviceCaps(hdc, LOGPIXELSY), 72);
  36. hFont = CreateFontIndirect (&lf);
  37. hFontBold = CreateFontIndirect (&lfb);
  38. hFontTitle = CreateFontIndirect (&lftitle);
  39. SetBkMode(hdc, TRANSPARENT);
  40. SelectObject(hdc, hFontTitle);
  41. SetTextColor(hdc, RGB(255,255,255));
  42. TextOut(hdc, 10, 10, wszHeader, wcslen(wszHeader));
  43. SetTextColor(hdc, 0);
  44. TextOut(hdc, 10, 45, wszSignInNameHdr, wcslen(wszSignInNameHdr));
  45. SelectObject(hdc, hFont);
  46. TextOut(hdc, 10, 60, g_wlmContactInfoWindow.wszContactID, 
  47. wcslen(g_wlmContactInfoWindow.wszContactID));
  48. SelectObject(hdc, hFontBold);
  49. TextOut(hdc, 10, 80, wszFdlyNameHdr, wcslen(wszFdlyNameHdr));
  50. SelectObject(hdc, hFont);
  51. TextOut(hdc, 10, 95, g_wlmContactInfoWindow.wszFriendlyName, 
  52. wcslen(g_wlmContactInfoWindow.wszFriendlyName));
  53. SelectObject(hdc, hFontBold);
  54. TextOut(hdc, 10, 115, wszStatusHeader, wcslen(wszStatusHeader));
  55. int i = 0;
  56. while (i < NUM_STATUS_STRINGS_ELEM && statStrings[i].msStat != g_wlmContactInfoWindow.msStatus) i++;
  57. SelectObject(hdc, hFont);
  58. TextOut(hdc, 10, 130, statStrings[i].wszStatus, wcslen(statStrings[i].wszStatus));
  59. SelectObject(hdc, hFontBold);
  60. TextOut(hdc, CIW_DEFAULT_WIDTH / 2, 115, wszBlockedHeader, wcslen(wszBlockedHeader));
  61. SelectObject(hdc, hFont);
  62. TextOut(hdc, CIW_DEFAULT_WIDTH / 2, 130, (g_wlmContactInfoWindow.fBlocked ? L"Yes" : L"No"), 
  63. wcslen(g_wlmContactInfoWindow.fBlocked ? L"Yes" : L"No"));
  64. SelectObject(hdc, hFontBold);
  65. TextOut(hdc, (CIW_DEFAULT_WIDTH / 2) + 50, 115, wszCanPageHeader, wcslen(wszCanPageHeader));
  66. SelectObject(hdc, hFont);
  67. TextOut(hdc, (CIW_DEFAULT_WIDTH / 2) + 50, 130, (g_wlmContactInfoWindow.fCanPage ? L"Yes" : L"No"), 
  68. wcslen(g_wlmContactInfoWindow.fCanPage ? L"Yes" : L"No"));
  69. SelectObject(hdc, hFontBold);
  70. TextOut(hdc, 10, 150, wszPhoneHomeHeader, wcslen(wszPhoneHomeHeader));
  71. SelectObject(hdc, hFont);
  72. if (g_wlmContactInfoWindow.wszHomePhone)
  73. TextOut(hdc, 10, 165, g_wlmContactInfoWindow.wszHomePhone, wcslen(g_wlmContactInfoWindow.wszHomePhone));
  74. else
  75. TextOut(hdc, 10, 165, L"N/A", wcslen(L"N/A"));
  76. SelectObject(hdc, hFontBold);
  77. TextOut(hdc, 10, 180, wszPhoneMobileHeader, wcslen(wszPhoneMobileHeader));
  78. SelectObject(hdc, hFont);
  79. if (g_wlmContactInfoWindow.wszMobilePhone)
  80. TextOut(hdc, 10, 195, g_wlmContactInfoWindow.wszMobilePhone, wcslen(g_wlmContactInfoWindow.wszMobilePhone));
  81. else
  82. TextOut(hdc, 10, 195, L"N/A", wcslen(L"N/A"));
  83. SelectObject(hdc, hFontBold);
  84. TextOut(hdc, 10, 215, wszPhoneWorkHeader, wcslen(wszPhoneWorkHeader));
  85. SelectObject(hdc, hFont);
  86. if (g_wlmContactInfoWindow.wszWorkPhone)
  87. TextOut(hdc, 10, 230, g_wlmContactInfoWindow.wszWorkPhone, wcslen(g_wlmContactInfoWindow.wszWorkPhone));
  88. else
  89. TextOut(hdc, 10, 230, L"N/A", wcslen(L"N/A"));
  90. DeleteObject(hFont);
  91. DeleteObject(hFontBold);
  92. DeleteObject(hFontTitle);
  93. }
  94. LRESULT ContactInfoWndProc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  95. {
  96. PAINTSTRUCT ps;
  97. HDC hdc;
  98. switch (msg)
  99. {
  100. case WM_PAINT:
  101. hdc = BeginPaint(hwnd, &ps);
  102. DrawTextStrings(hdc);
  103. EndPaint(hwnd, &ps);
  104. return 0L;
  105. case WM_NCHITTEST: // prevent dragging
  106. return 0L;
  107. }
  108. return CallWindowProc(pfnColorizedWndProc, hwnd,msg,wparam,lparam);
  109. }
  110. void CreateContactInfoWnd(HWND* pHWnd)
  111. {
  112. // Create the contact info window with the colorized window class
  113. *pHWnd = CreateWindowEx(WS_EX_NOACTIVATE, wszColorizedWndClass, NULL, WS_POPUP, 
  114. 0, 0, CIW_DEFAULT_WIDTH, CIW_DEFAULT_HEIGHT, 
  115. NULL, NULL, hDllInst, NULL );
  116. // window subclassing
  117. if (*pHWnd)
  118. {
  119. pfnColorizedWndProc = (WNDPROC) GetWindowLongPtr(*pHWnd, GWLP_WNDPROC);
  120. SetWindowLongPtr(*pHWnd, GWLP_WNDPROC, (LONG_PTR)ContactInfoWndProc );
  121. }
  122. }