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.

362 lines
9.2 KiB

  1. /* File: D:\WACKER\tdll\aboutdlg.c (Created: 04-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 21 $
  7. * $Date: 4/16/02 2:36p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <commctrl.h>
  12. #include <term\res.h>
  13. #include "banner.h"
  14. #include "globals.h"
  15. #include "features.h"
  16. #include "misc.h"
  17. #include "upgrddlg.h"
  18. #include "registry.h"
  19. #if !defined(NT_EDITION)
  20. #if defined(INCL_PRIVATE_EDITION_BANNER)
  21. #include "stdtyp.h"
  22. #include <emu\emu.h>
  23. #include "term.hh" // This must be after emu.h
  24. INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar);
  25. LRESULT CALLBACK BannerAboutProc(HWND hwnd, UINT uMsg, WPARAM wPar, LPARAM lPar);
  26. DWORD CALLBACK EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff,
  27. LONG cb, LONG *pcb);
  28. #endif
  29. #endif
  30. static const TCHAR g_achHyperTerminalRegKey[] =
  31. TEXT("SOFTWARE\\Hilgraeve Inc\\HyperTerminal PE\\3.0");
  32. static const TCHAR g_achSerial[] = TEXT("Registered");
  33. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  34. * FUNCTION:
  35. * AboutDlg
  36. *
  37. * DESCRIPTION:
  38. *
  39. * ARGUMENTS:
  40. * hwnd - session window handle
  41. *
  42. * RETURNS:
  43. * void
  44. *
  45. */
  46. void AboutDlg(HWND hwndSession)
  47. {
  48. #if defined(NT_EDITION)
  49. TCHAR ach1[100];
  50. TCHAR ach2[100];
  51. HINSTANCE hInst = glblQueryDllHinst();
  52. HICON lTermIcon = extLoadIcon(MAKEINTRESOURCE(IDI_HYPERTERMINAL));
  53. int lReturn;
  54. LoadString(hInst, IDS_GNRL_APPNAME, ach1,
  55. sizeof(ach1) / sizeof(TCHAR));
  56. LoadString(hInst, IDS_GNRL_HILGRAVE_COPYRIGHT, ach2,
  57. sizeof(ach2) / sizeof(TCHAR));
  58. lReturn = ShellAbout(hwndSession,
  59. ach1,
  60. ach2,
  61. lTermIcon);
  62. #else // NT_EDITION
  63. #if defined(INCL_PRIVATE_EDITION_BANNER)
  64. DialogBox(glblQueryDllHinst(), MAKEINTRESOURCE(IDD_ABOUT_DLG),
  65. hwndSession, AboutDlgProc);
  66. #else
  67. TCHAR ach1[100];
  68. HWND hwndAbout;
  69. LoadString(glblQueryDllHinst(), IDS_GNRL_APPNAME, ach1,
  70. sizeof(ach1) / sizeof(TCHAR));
  71. hwndAbout = CreateWindow(BANNER_DISPLAY_CLASS,
  72. ach1,
  73. WS_CHILD | WS_VISIBLE,
  74. 0,
  75. 0,
  76. 100,
  77. 100,
  78. hwndSession,
  79. NULL,
  80. glblQueryDllHinst(),
  81. NULL);
  82. UpdateWindow(hwndAbout);
  83. #endif
  84. #endif // NT_EDITION
  85. return;
  86. }
  87. // ----------------- Private edition about dialog routines ------------------
  88. //
  89. #if !defined(NT_EDITION)
  90. #if defined(INCL_PRIVATE_EDITION_BANNER)
  91. #define BANNER_ABOUT_CLASS "Banner About Class"
  92. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  93. * FUNCTION:
  94. * AboutDlgProc
  95. *
  96. * DESCRIPTION:
  97. *
  98. */
  99. INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  100. {
  101. #define IDPB_UPGRADE 100
  102. HWND hwndAbout;
  103. switch (wMsg)
  104. {
  105. case WM_INITDIALOG:
  106. hwndAbout = CreateWindow(BANNER_ABOUT_CLASS,
  107. NULL,
  108. WS_CHILD | WS_VISIBLE,
  109. 0,
  110. 0,
  111. 100,
  112. 100,
  113. hDlg,
  114. NULL,
  115. glblQueryDllHinst(),
  116. NULL);
  117. break;
  118. case WM_COMMAND:
  119. switch (wPar)
  120. {
  121. case IDOK:
  122. case IDCANCEL:
  123. EndDialog(hDlg, TRUE);
  124. break;
  125. case IDPB_UPGRADE:
  126. DoUpgradeDialog(hDlg);
  127. break;
  128. default:
  129. break;
  130. }
  131. break;
  132. default:
  133. return FALSE;
  134. }
  135. return TRUE;
  136. }
  137. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  138. * FUNCTION: RegisterBannerAboutClass
  139. *
  140. * DESCRIPTION:
  141. * This function registers the window class for the banner window.
  142. *
  143. * ARGUEMENTS:
  144. * The task instance handle.
  145. *
  146. * RETURNS:
  147. * The usual TRUE/FALSE from a registration function.
  148. *
  149. */
  150. BOOL RegisterBannerAboutClass(HANDLE hInstance)
  151. {
  152. ATOM bRet = TRUE;
  153. WNDCLASSEX wnd;
  154. memset(&wnd, 0, sizeof(WNDCLASSEX));
  155. wnd.cbSize = sizeof(WNDCLASSEX);
  156. if (GetClassInfoEx(hInstance, BANNER_ABOUT_CLASS, &wnd) == FALSE)
  157. {
  158. wnd.style = CS_HREDRAW | CS_VREDRAW;
  159. wnd.lpfnWndProc = BannerAboutProc;
  160. wnd.cbClsExtra = 0;
  161. wnd.cbWndExtra = sizeof(HANDLE);
  162. wnd.hInstance = hInstance;
  163. wnd.hIcon = extLoadIcon(MAKEINTRESOURCE(IDI_HYPERTERMINAL));
  164. wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
  165. wnd.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  166. wnd.lpszMenuName = NULL;
  167. wnd.lpszClassName = BANNER_ABOUT_CLASS;
  168. wnd.hIconSm = extLoadIcon(MAKEINTRESOURCE(IDI_HYPERTERMINAL));
  169. bRet = RegisterClassEx(&wnd);
  170. }
  171. return bRet;
  172. }
  173. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  174. * FUNCTION:
  175. * AboutDlgProc
  176. *
  177. * DESCRIPTION:
  178. * Pops up the about dialog. In the private edition, this is an actual
  179. * dialog of some complexity.
  180. *
  181. */
  182. LRESULT CALLBACK BannerAboutProc(HWND hwnd, UINT uMsg, WPARAM wPar, LPARAM lPar)
  183. {
  184. RECT rc;
  185. HBITMAP hBitmap = (HBITMAP)0;
  186. BITMAP bm;
  187. INT x, y, cx, cy;
  188. HDC hDC;
  189. PAINTSTRUCT ps;
  190. LOGFONT lf;
  191. HFONT hFont;
  192. TCHAR atchSerialNumber[MAX_PATH * 2];
  193. DWORD dwSize = sizeof(atchSerialNumber);
  194. switch (uMsg)
  195. {
  196. case WM_CREATE:
  197. //mpt:03-12-98 Changed the bitmap and avi to use system colors
  198. //hBitmap = LoadBitmap(glblQueryDllHinst(), MAKEINTRESOURCE(IDD_BM_BANNER));
  199. hBitmap = (HBITMAP)LoadImage(glblQueryDllHinst(),
  200. MAKEINTRESOURCE(IDD_BM_BANNER),
  201. IMAGE_BITMAP,
  202. 0,
  203. 0,
  204. LR_CREATEDIBSECTION | LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS);
  205. SetWindowLongPtr(hwnd, 0, (LONG_PTR)hBitmap);
  206. GetObject(hBitmap, sizeof(BITMAP), (LPTSTR)&bm);
  207. SetRect(&rc, 0, 0, bm.bmWidth, bm.bmHeight);
  208. AdjustWindowRect(&rc, WS_CHILD | WS_VISIBLE, FALSE);
  209. cx = rc.right - rc.left;
  210. cy = rc.bottom - rc.top;
  211. GetClientRect(GetParent(hwnd), &rc);
  212. x = (rc.right - cx) / 2;
  213. y = (rc.bottom - cy) / 3;
  214. MoveWindow(hwnd, x, y, cx, cy, TRUE);
  215. #if defined(INCL_SPINNING_GLOBE)
  216. // Create an animation control and play spinning globe.
  217. //
  218. {
  219. HWND hwndAnimate;
  220. //mpt:03-12-98 Changed the bitmap and avi to use system colors
  221. hwndAnimate = Animate_Create(hwnd, 100,
  222. WS_VISIBLE | WS_CHILD | ACS_TRANSPARENT,
  223. glblQueryDllHinst());
  224. MoveWindow(hwndAnimate, 177, 37, 118, 101, TRUE);
  225. Animate_Open(hwndAnimate, MAKEINTRESOURCE(IDR_GLOBE_AVI));
  226. if (!IsTerminalServicesEnabled())
  227. {
  228. Animate_Play(hwndAnimate, 0, -1, 1);
  229. }
  230. }
  231. #endif
  232. break;
  233. case WM_PAINT:
  234. hDC = BeginPaint(hwnd, &ps);
  235. hBitmap = (HBITMAP)GetWindowLongPtr(hwnd, 0);
  236. if (hBitmap)
  237. utilDrawBitmap((HWND)0, hDC, hBitmap, 0, 0);
  238. // In the HTPE 3 banner, the version # and lot # are now in the
  239. // lower left corner of the bitmap. - cab:11/29/96
  240. //
  241. // #if !defined(USE_PRIVATE_EDITION_3_BANNER)
  242. // Here's a mean trick. The HwndFrame guy doesn't get set until
  243. // long after the banner goes up. Since we don't want the version
  244. // number on the opening banner but do want it in the about portion
  245. // this works. - mrw:3/17/95
  246. //
  247. if (glblQueryHwndFrame())
  248. {
  249. memset(&lf, 0, sizeof(LOGFONT));
  250. lf.lfHeight = 14;
  251. lf.lfCharSet = ANSI_CHARSET;
  252. //lf.lfWeight = FW_SEMIBOLD;
  253. strcpy(lf.lfFaceName, "Arial");
  254. hFont = CreateFontIndirect(&lf);
  255. if (hFont)
  256. {
  257. hFont = SelectObject(hDC, hFont);
  258. //SetBkColor(hDC, RGB(0,255,0));
  259. SetBkMode( hDC, TRANSPARENT );
  260. TextOut(hDC, 19, 230, "Build Date", 10);
  261. TextOut(hDC, 19, 242, __DATE__, strlen(__DATE__));
  262. TextOut(hDC, 225, 230, "Copyright� 2001", 15);
  263. TextOut(hDC, 225, 242, "Hilgraeve Inc.", 14);
  264. DeleteObject(SelectObject(hDC, hFont));
  265. // Draw in the version number
  266. //
  267. if ( htRegQueryValue(HKEY_CURRENT_USER,
  268. g_achHyperTerminalRegKey,
  269. g_achSerial,
  270. atchSerialNumber,
  271. &dwSize) == 0 )
  272. {
  273. hFont = SelectObject(hDC, hFont);
  274. SetBkColor(hDC, GetSysColor(COLOR_BTNFACE));
  275. TextOut(hDC, 15, 12, atchSerialNumber, strlen(atchSerialNumber));
  276. DeleteObject(SelectObject(hDC, hFont));
  277. }
  278. }
  279. }
  280. // #endif
  281. EndPaint(hwnd, &ps);
  282. break;
  283. case WM_LBUTTONDOWN:
  284. DoUpgradeDialog(hwnd);
  285. break;
  286. default:
  287. break;
  288. }
  289. return DefWindowProc(hwnd, uMsg, wPar, lPar);
  290. }
  291. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  292. * FUNCTION: UnregisterBannerAboutClass
  293. *
  294. * DESCRIPTION:
  295. * This function registers the window class for the banner window.
  296. *
  297. * ARGUEMENTS:
  298. * The task instance handle.
  299. *
  300. * RETURNS:
  301. * The usual TRUE/FALSE from a registration function.
  302. *
  303. */
  304. BOOL UnregisterBannerAboutClass(HANDLE hInstance)
  305. {
  306. return UnregisterClass(BANNER_ABOUT_CLASS, hInstance);
  307. }
  308. #endif //INCL_PRIVATE_EDITION_BANNER
  309. #endif //!NT_EDITION