Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.3 KiB

  1. #ifndef WIN32_LEAN_AND_MEAN
  2. #define WIN32_LEAN_AND_MEAN
  3. #endif
  4. #include <windows.h>
  5. #include <windowsx.h>
  6. #include <commctrl.h>
  7. #include "cdwtt.h"
  8. #ifdef UNDER_CE // Windows CE specific
  9. #include "stub_ce.h" // Windows CE stub for unsupported APIs
  10. #endif // UNDER_CE
  11. // Safe String
  12. #define STRSAFE_NO_DEPRECATE
  13. #include "strsafe.h"
  14. #ifndef UNDER_CE
  15. static char g_szClass[]="fdwtooltip";
  16. #else // UNDER_CE
  17. static TCHAR g_szClass[]=TEXT("fdwtooltip");
  18. #endif // UNDER_CE
  19. #ifdef UNDER_CE // In Windows CE, all window classes are process global.
  20. static LPCTSTR MakeClassName(HINSTANCE hInst, LPTSTR lpszBuf)
  21. {
  22. // make module unique name
  23. TCHAR szFileName[MAX_PATH];
  24. GetModuleFileName(hInst, szFileName, MAX_PATH);
  25. LPTSTR lpszFName = _tcsrchr(szFileName, TEXT('\\'));
  26. if(lpszFName) *lpszFName = TEXT('_');
  27. StringCchCopy(lpszBuf, MAX_PATH, g_szClass);
  28. StringCchCat(lpszBuf, MAX_PATH, lpszFName);
  29. return lpszBuf;
  30. }
  31. BOOL ToolTip_UnregisterClass(HINSTANCE hInst)
  32. {
  33. TCHAR szClassName[MAX_PATH];
  34. return UnregisterClass(MakeClassName(hInst, szClassName), hInst);
  35. }
  36. #endif // UNDER_CE
  37. HWND WINAPI ToolTip_CreateWindow(HINSTANCE hInst, DWORD dwStyle, HWND hwndOwner)
  38. {
  39. #ifndef UNDER_CE // Windows CE does not support EX
  40. WNDCLASSEX wc;
  41. if(!::GetClassInfoEx(hInst, g_szClass, &wc)) {
  42. #else // UNDER_CE
  43. TCHAR szClassName[MAX_PATH];
  44. WNDCLASS wc;
  45. if(!::GetClassInfo(hInst, MakeClassName(hInst, szClassName), &wc)) {
  46. #endif // UNDER_CE
  47. ::ZeroMemory(&wc, sizeof(wc));
  48. #ifndef UNDER_CE // Windows CE does not support EX
  49. wc.cbSize = sizeof(wc);
  50. #endif // UNDER_CE
  51. wc.style = CS_HREDRAW | CS_VREDRAW;
  52. wc.lpfnWndProc = (WNDPROC)CDWToolTip::WndProc;
  53. wc.cbClsExtra = 0;
  54. wc.cbWndExtra = 0;
  55. wc.hInstance = hInst;
  56. wc.hIcon = NULL;
  57. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  58. wc.hbrBackground = (HBRUSH)NULL;
  59. wc.lpszMenuName = NULL;
  60. #ifndef UNDER_CE // In Windows CE, all window classes are process global.
  61. wc.lpszClassName = g_szClass;
  62. #else // UNDER_CE
  63. wc.lpszClassName = szClassName;
  64. #endif // UNDER_CE
  65. #ifndef UNDER_CE // Windows CE does not support EX
  66. wc.hIconSm = NULL;
  67. ::RegisterClassEx(&wc);
  68. #else // UNDER_CE
  69. ::RegisterClass(&wc);
  70. #endif // UNDER_CE
  71. }
  72. HWND hwnd;
  73. //----------------------------------------------------------------
  74. //for Satori #2239.
  75. //If create window with WS_DISABLED, AnimateWindow change cursor as hourglass.
  76. //So, removed WS_DISABLED.
  77. //----------------------------------------------------------------
  78. //00/08/08: This fix is NOT enough...
  79. //Tooltip gets focus...
  80. //----------------------------------------------------------------
  81. hwnd = ::CreateWindowEx(0,
  82. #ifndef UNDER_CE // In Windows CE, all window classes are process global.
  83. g_szClass,
  84. #else // UNDER_CE
  85. szClassName,
  86. #endif // UNDER_CE
  87. NULL,
  88. //dwStyle | WS_POPUP | WS_BORDER | WS_VISIBLE, //WS_DISABLED,
  89. dwStyle | WS_POPUP | WS_BORDER | WS_DISABLED,
  90. 0, 0, 0, 0,
  91. hwndOwner,
  92. NULL,
  93. hInst,
  94. NULL);
  95. return hwnd;
  96. }
  97. INT WINAPI ToolTip_Enable(HWND hwndToolTip, BOOL fEnable)
  98. {
  99. LPCDWToolTip lpCDWTT = (LPCDWToolTip)GetHWNDPtr(hwndToolTip);
  100. if(lpCDWTT) {
  101. lpCDWTT->Enable(hwndToolTip, fEnable);
  102. }
  103. return 0;
  104. }