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.

708 lines
18 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998 Active Voice Corporation. All Rights Reserved.
  4. //
  5. // Active Agent(r) and Unified Communications(tm) are trademarks of Active Voice Corporation.
  6. //
  7. // Other brand and product names used herein are trademarks of their respective owners.
  8. //
  9. // The entire program and user interface including the structure, sequence, selection,
  10. // and arrangement of the dialog, the exclusively "yes" and "no" choices represented
  11. // by "1" and "2," and each dialog message are protected by copyrights registered in
  12. // the United States and by international treaties.
  13. //
  14. // Protected by one or more of the following United States patents: 5,070,526, 5,488,650,
  15. // 5,434,906, 5,581,604, 5,533,102, 5,568,540, 5,625,676, 5,651,054.
  16. //
  17. // Active Voice Corporation
  18. // Seattle, Washington
  19. // USA
  20. //
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. ////
  23. // splash.c - splash screen functions
  24. ////
  25. #include "winlocal.h"
  26. #include <stdlib.h>
  27. #include "splash.h"
  28. #include "gfx.h"
  29. #include "mem.h"
  30. #include "trace.h"
  31. #include "wnd.h"
  32. ////
  33. // private definitions
  34. ////
  35. #define SPLASHCLASS TEXT("SplashClass")
  36. #define ID_TIMER_MINSHOW 100
  37. #define ID_TIMER_MAXSHOW 200
  38. // splash control struct
  39. //
  40. typedef struct SPLASH
  41. {
  42. DWORD dwVersion;
  43. HINSTANCE hInst;
  44. HTASK hTask;
  45. UINT msMinShow;
  46. UINT msMaxShow;
  47. DWORD dwFlags;
  48. HWND hwndSplash;
  49. HBITMAP hBitmap;
  50. BOOL fVisible;
  51. BOOL fHideAfterMinShowTimer;
  52. BOOL fMinShowTimerSet;
  53. BOOL fMaxShowTimerSet;
  54. } SPLASH, FAR *LPSPLASH;
  55. // helper functions
  56. //
  57. LRESULT DLLEXPORT CALLBACK SplashWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  58. static BOOL SplashOnNCCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct);
  59. static void SplashOnPaint(HWND hwnd);
  60. static void SplashOnTimer(HWND hwnd, UINT id);
  61. static UINT SplashOnNCHitTest(HWND hwnd, int x, int y);
  62. static void SplashOnChar(HWND hwnd, UINT ch, int cRepeat);
  63. static void SplashOnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags);
  64. static void SplashOnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags);
  65. static int SplashAbort(LPSPLASH lpSplash);
  66. static LPSPLASH SplashGetPtr(HSPLASH hSplash);
  67. static HSPLASH SplashGetHandle(LPSPLASH lpSplash);
  68. ////
  69. // public functions
  70. ////
  71. // SplashCreate - create splash screen
  72. // <dwVersion> (i) must be SPLASH_VERSION
  73. // <hInst> (i) instance handle of calling module
  74. // <hwndParent> (i) window which will own the splash screen
  75. // NULL desktop window
  76. // <hBitmapMono> (i) bitmap to display on mono displays
  77. // <hBitmapColor> (i) bitmap to display on color displays
  78. // 0 use mono bitmap
  79. // <msMinShow> (i) minimum time (ms) to show splash screen
  80. // 0 no minimum time
  81. // <msMaxShow> (i) maximum time (ms) to show splash screen
  82. // 0 no maximum time
  83. // <dwFlags> (i) control flags
  84. // SPLASH_SETFOCUS SplashShow will set focus to splash screen
  85. // SPLASH_NOFOCUS user cannot set focus to splash screen
  86. // SPLASH_ABORT user can hide splash screen w/mouse or keybd
  87. // SPLASH_NOMOVE user cannot move the splash screen w/mouse
  88. // return handle (NULL if error)
  89. //
  90. // NOTE: SplashCreate creates the window but does not show it.
  91. // See SplashShow and SplashHide
  92. //
  93. HSPLASH DLLEXPORT WINAPI SplashCreate(DWORD dwVersion, HINSTANCE hInst,
  94. HWND hwndParent, HBITMAP hBitmapMono, HBITMAP hBitmapColor,
  95. UINT msMinShow, UINT msMaxShow, DWORD dwFlags)
  96. {
  97. BOOL fSuccess = TRUE;
  98. LPSPLASH lpSplash = NULL;
  99. WNDCLASS wc;
  100. if (dwVersion != SPLASH_VERSION)
  101. fSuccess = TraceFALSE(NULL);
  102. else if (hInst == NULL)
  103. fSuccess = TraceFALSE(NULL);
  104. else if ((lpSplash = (LPSPLASH) MemAlloc(NULL, sizeof(SPLASH), 0)) == NULL)
  105. fSuccess = TraceFALSE(NULL);
  106. else
  107. {
  108. lpSplash->dwVersion = dwVersion;
  109. lpSplash->hInst = hInst;
  110. lpSplash->hTask = GetCurrentTask();
  111. lpSplash->msMinShow = msMinShow;
  112. lpSplash->msMaxShow = msMaxShow;
  113. lpSplash->dwFlags = dwFlags;
  114. lpSplash->hwndSplash = NULL;
  115. lpSplash->hBitmap = NULL;
  116. lpSplash->fVisible = FALSE;
  117. lpSplash->fHideAfterMinShowTimer = FALSE;
  118. lpSplash->fMinShowTimerSet = FALSE;
  119. lpSplash->fMaxShowTimerSet = FALSE;
  120. if (hwndParent == NULL)
  121. hwndParent = GetDesktopWindow();
  122. // store either the mono or color bitmap, as appropriate
  123. //
  124. if (GfxDeviceIsMono(NULL) || hBitmapColor == 0)
  125. lpSplash->hBitmap = hBitmapMono;
  126. else
  127. lpSplash->hBitmap = hBitmapColor;
  128. }
  129. // register splash screen class unless it has been already
  130. //
  131. if (fSuccess && GetClassInfo(lpSplash->hInst, SPLASHCLASS, &wc) == 0)
  132. {
  133. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  134. wc.hIcon = (HICON) NULL;
  135. wc.lpszMenuName = NULL;
  136. wc.hInstance = lpSplash->hInst;
  137. wc.lpszClassName = SPLASHCLASS;
  138. wc.hbrBackground = NULL;
  139. wc.lpfnWndProc = SplashWndProc;
  140. wc.style = 0L;
  141. wc.cbWndExtra = sizeof(lpSplash);
  142. wc.cbClsExtra = 0;
  143. if (!RegisterClass(&wc))
  144. fSuccess = TraceFALSE(NULL);
  145. }
  146. // create a splash screen window
  147. //
  148. if (fSuccess && (lpSplash->hwndSplash = CreateWindowEx(
  149. 0L,
  150. SPLASHCLASS,
  151. (LPTSTR) TEXT(""),
  152. WS_POPUP,
  153. 0, 0, 0, 0, // we will calculate size and position later
  154. hwndParent,
  155. (HMENU) NULL,
  156. lpSplash->hInst,
  157. lpSplash)) == NULL)
  158. {
  159. fSuccess = TraceFALSE(NULL);
  160. }
  161. if (fSuccess)
  162. {
  163. BITMAP Bitmap;
  164. // the size of the window is equal to the size of the bitmap
  165. //
  166. if (GetObject((HGDIOBJ) lpSplash->hBitmap, sizeof(BITMAP), &Bitmap) == 0)
  167. fSuccess = TraceFALSE(NULL);
  168. else if (!SetWindowPos(lpSplash->hwndSplash,
  169. NULL, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight,
  170. SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER))
  171. fSuccess = TraceFALSE(NULL);
  172. }
  173. if (fSuccess)
  174. {
  175. int cxOffCenter = 0;
  176. int cyOffCenter = 0;
  177. // try to avoid having the window overlap
  178. // the icons at the bottom of the desktop window
  179. //
  180. if (hwndParent == GetDesktopWindow())
  181. {
  182. #if 0
  183. cyOffCenter = -1 * ((GetSystemMetrics(SM_CYICON) +
  184. GetSystemMetrics(SM_CYCAPTION) * 2) / 2);
  185. #endif
  186. }
  187. // center the window on its parent
  188. //
  189. if (WndCenterWindow(lpSplash->hwndSplash,
  190. hwndParent, cxOffCenter, cyOffCenter) != 0)
  191. {
  192. fSuccess = TraceFALSE(NULL);
  193. }
  194. }
  195. if (!fSuccess)
  196. {
  197. SplashDestroy(SplashGetHandle(lpSplash));
  198. lpSplash = NULL;
  199. }
  200. return fSuccess ? SplashGetHandle(lpSplash) : NULL;
  201. }
  202. // SplashDestroy - destroy splash screen
  203. // <hSplash> (i) handle returned from SplashCreate
  204. // return 0 if success
  205. //
  206. // NOTE: SplashDestroy always destroys the splash screen,
  207. // whether or not the minimum show time has elapsed.
  208. //
  209. int DLLEXPORT WINAPI SplashDestroy(HSPLASH hSplash)
  210. {
  211. BOOL fSuccess = TRUE;
  212. LPSPLASH lpSplash;
  213. if (SplashHide(hSplash) != 0)
  214. fSuccess = TraceFALSE(NULL);
  215. else if ((lpSplash = SplashGetPtr(hSplash)) == NULL)
  216. fSuccess = TraceFALSE(NULL);
  217. else if (lpSplash->hwndSplash != NULL &&
  218. !DestroyWindow(lpSplash->hwndSplash))
  219. fSuccess = TraceFALSE(NULL);
  220. else if ((lpSplash = MemFree(NULL, lpSplash)) != NULL)
  221. fSuccess = TraceFALSE(NULL);
  222. return fSuccess ? 0 : -1;
  223. }
  224. // SplashShow - show splash screen
  225. // <hSplash> (i) handle returned from SplashCreate
  226. // return 0 if success
  227. //
  228. // NOTE: SplashShow() makes the splash screen visible. Also, timers are
  229. // initiated for minimum and maximum show times, if they were specified.
  230. //
  231. int DLLEXPORT WINAPI SplashShow(HSPLASH hSplash)
  232. {
  233. BOOL fSuccess = TRUE;
  234. LPSPLASH lpSplash;
  235. if ((lpSplash = SplashGetPtr(hSplash)) == NULL)
  236. fSuccess = TraceFALSE(NULL);
  237. else if (lpSplash->fVisible)
  238. ; // already visible, so no need to do anything else
  239. else
  240. {
  241. // prevent user input if SPLASH_NOFOCUS flag set
  242. //
  243. if (lpSplash->dwFlags & SPLASH_NOFOCUS)
  244. EnableWindow(lpSplash->hwndSplash, FALSE);
  245. // show the window
  246. //
  247. ShowWindow(lpSplash->hwndSplash, SW_SHOW);
  248. UpdateWindow(lpSplash->hwndSplash);
  249. lpSplash->fVisible = TRUE;
  250. // set focus to splash screen if SPLASH_SETFOCUS flag set
  251. //
  252. if (lpSplash->dwFlags & SPLASH_SETFOCUS)
  253. SetFocus(lpSplash->hwndSplash);
  254. // set min show timer if necessary
  255. //
  256. if (!lpSplash->fMinShowTimerSet &&
  257. lpSplash->msMinShow > 0)
  258. {
  259. if (!SetTimer(lpSplash->hwndSplash, ID_TIMER_MINSHOW,
  260. lpSplash->msMinShow, NULL))
  261. fSuccess = TraceFALSE(NULL);
  262. else
  263. lpSplash->fMinShowTimerSet = TRUE;
  264. }
  265. // set max show timer if necessary
  266. //
  267. if (!lpSplash->fMaxShowTimerSet &&
  268. lpSplash->msMaxShow > 0)
  269. {
  270. if (!SetTimer(lpSplash->hwndSplash, ID_TIMER_MAXSHOW,
  271. lpSplash->msMaxShow, NULL))
  272. fSuccess = TraceFALSE(NULL);
  273. else
  274. lpSplash->fMaxShowTimerSet = TRUE;
  275. }
  276. }
  277. return fSuccess ? 0 : -1;
  278. }
  279. // SplashHide - hide splash screen
  280. // <hSplash> (i) handle returned from SplashCreate
  281. // return 0 if success
  282. //
  283. // NOTE: SplashHide() will hide the splash screen, unless
  284. // 1) the minimum show time has not yet elapsed. If not,
  285. // the splash screen will remain visible until then.
  286. // 2) the maximum show time has already elapsed. If so,
  287. // the splash screen has already been hidden.
  288. //
  289. int DLLEXPORT WINAPI SplashHide(HSPLASH hSplash)
  290. {
  291. BOOL fSuccess = TRUE;
  292. LPSPLASH lpSplash;
  293. if ((lpSplash = SplashGetPtr(hSplash)) == NULL)
  294. fSuccess = TraceFALSE(NULL);
  295. else if (!lpSplash->fVisible)
  296. ; // already hidden, so no need to do anything else
  297. else if (lpSplash->fMinShowTimerSet)
  298. {
  299. // minimum show time not yet elapsed
  300. // set a flag so we know to hide window later
  301. //
  302. lpSplash->fHideAfterMinShowTimer = TRUE;
  303. }
  304. else
  305. {
  306. // hide the window
  307. //
  308. ShowWindow(lpSplash->hwndSplash, SW_HIDE);
  309. lpSplash->fVisible = FALSE;
  310. lpSplash->fHideAfterMinShowTimer = FALSE;
  311. // kill min show timer if necessary
  312. //
  313. if (lpSplash->fMinShowTimerSet &&
  314. !KillTimer(lpSplash->hwndSplash, ID_TIMER_MINSHOW))
  315. fSuccess = TraceFALSE(NULL);
  316. else
  317. lpSplash->fMinShowTimerSet = FALSE;
  318. // kill max show timer if necessary
  319. //
  320. if (lpSplash->fMaxShowTimerSet &&
  321. !KillTimer(lpSplash->hwndSplash, ID_TIMER_MAXSHOW))
  322. fSuccess = TraceFALSE(NULL);
  323. else
  324. lpSplash->fMaxShowTimerSet = FALSE;
  325. }
  326. return fSuccess ? 0 : -1;
  327. }
  328. // SplashIsVisible - get visible flag
  329. // <hSplash> (i) handle returned from SplashCreate
  330. // return TRUE if splash screen is visible, FALSE if hidden or error
  331. //
  332. int DLLEXPORT WINAPI SplashIsVisible(HSPLASH hSplash)
  333. {
  334. BOOL fSuccess = TRUE;
  335. LPSPLASH lpSplash;
  336. if ((lpSplash = SplashGetPtr(hSplash)) == NULL)
  337. fSuccess = TraceFALSE(NULL);
  338. return fSuccess ? lpSplash->fVisible : FALSE;
  339. }
  340. // SplashGetWindowHandle - get splash screen window handle
  341. // <hSplash> (i) handle returned from SplashCreate
  342. // return window handle (NULL if error)
  343. //
  344. HWND DLLEXPORT WINAPI SplashGetWindowHandle(HSPLASH hSplash)
  345. {
  346. BOOL fSuccess = TRUE;
  347. LPSPLASH lpSplash;
  348. if ((lpSplash = SplashGetPtr(hSplash)) == NULL)
  349. fSuccess = TraceFALSE(NULL);
  350. return fSuccess ? lpSplash->hwndSplash : NULL;
  351. }
  352. ////
  353. // helper functions
  354. ////
  355. // SplashWndProc - window procedure for splash screen
  356. //
  357. LRESULT DLLEXPORT CALLBACK SplashWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  358. {
  359. BOOL fSuccess = TRUE;
  360. LRESULT lResult;
  361. switch (msg)
  362. {
  363. case WM_NCCREATE:
  364. lResult = (LRESULT) HANDLE_WM_NCCREATE(hwnd, wParam, lParam, SplashOnNCCreate);
  365. break;
  366. case WM_PAINT:
  367. lResult = (LRESULT) HANDLE_WM_PAINT(hwnd, wParam, lParam, SplashOnPaint);
  368. break;
  369. case WM_TIMER:
  370. lResult = (LRESULT) HANDLE_WM_TIMER(hwnd, wParam, lParam, SplashOnTimer);
  371. break;
  372. case WM_NCHITTEST:
  373. lResult = (LRESULT) HANDLE_WM_NCHITTEST(hwnd, wParam, lParam, SplashOnNCHitTest);
  374. break;
  375. case WM_CHAR:
  376. lResult = (LRESULT) HANDLE_WM_CHAR(hwnd, wParam, lParam, SplashOnChar);
  377. break;
  378. case WM_LBUTTONDOWN:
  379. lResult = (LRESULT) HANDLE_WM_LBUTTONDOWN(hwnd, wParam, lParam, SplashOnLButtonDown);
  380. break;
  381. case WM_RBUTTONDOWN:
  382. lResult = (LRESULT) HANDLE_WM_RBUTTONDOWN(hwnd, wParam, lParam, SplashOnRButtonDown);
  383. break;
  384. default:
  385. lResult = DefWindowProc(hwnd, msg, wParam, lParam);
  386. break;
  387. }
  388. return lResult;
  389. }
  390. // SplashOnNCCreate - handler for WM_NCCREATE message
  391. //
  392. static BOOL SplashOnNCCreate(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct)
  393. {
  394. LPSPLASH lpSplash = (LPSPLASH) lpCreateStruct->lpCreateParams;
  395. lpSplash->hwndSplash = hwnd;
  396. // store lpSplash in window extra bytes
  397. //
  398. SetWindowLongPtr(hwnd, 0, (LONG_PTR) lpSplash);
  399. return FORWARD_WM_NCCREATE(hwnd, lpCreateStruct, DefWindowProc);
  400. }
  401. // SplashOnPaint - handler for WM_PAINT message
  402. //
  403. static void SplashOnPaint(HWND hwnd)
  404. {
  405. HDC hdc;
  406. PAINTSTRUCT ps;
  407. // retrieve lpSplash from window extra bytes
  408. //
  409. LPSPLASH lpSplash = (LPSPLASH) GetWindowLongPtr(hwnd, 0);
  410. hdc = BeginPaint(hwnd, &ps);
  411. // display splash screen bitmap
  412. //
  413. GfxBitmapDisplay(hdc, lpSplash->hBitmap, 0, 0, FALSE);
  414. EndPaint(hwnd, &ps);
  415. return;
  416. }
  417. // SplashOnTimer - handler for WM_TIMER message
  418. //
  419. static void SplashOnTimer(HWND hwnd, UINT id)
  420. {
  421. BOOL fSuccess = TRUE;
  422. // retrieve lpSplash from window extra bytes
  423. //
  424. LPSPLASH lpSplash = (LPSPLASH) GetWindowLongPtr(hwnd, 0);
  425. switch (id)
  426. {
  427. case ID_TIMER_MINSHOW:
  428. {
  429. // kill the timer so it does not repeat
  430. //
  431. if (lpSplash->fMinShowTimerSet &&
  432. !KillTimer(lpSplash->hwndSplash, ID_TIMER_MINSHOW))
  433. fSuccess = TraceFALSE(NULL);
  434. else
  435. {
  436. lpSplash->fMinShowTimerSet = FALSE;
  437. // hide window if SplashHide was called earlier
  438. //
  439. if (lpSplash->fVisible &&
  440. lpSplash->fHideAfterMinShowTimer &&
  441. SplashHide(SplashGetHandle(lpSplash)) != 0)
  442. fSuccess = TraceFALSE(NULL);
  443. }
  444. }
  445. break;
  446. case ID_TIMER_MAXSHOW:
  447. {
  448. // kill the timer so it does not repeat
  449. //
  450. if (lpSplash->fMaxShowTimerSet &&
  451. !KillTimer(lpSplash->hwndSplash, ID_TIMER_MAXSHOW))
  452. fSuccess = TraceFALSE(NULL);
  453. else
  454. {
  455. lpSplash->fMaxShowTimerSet = FALSE;
  456. // hide window if max show time expired
  457. //
  458. if (lpSplash->fVisible &&
  459. SplashHide(SplashGetHandle(lpSplash)) != 0)
  460. fSuccess = TraceFALSE(NULL);
  461. }
  462. }
  463. break;
  464. default:
  465. break;
  466. }
  467. return;
  468. }
  469. // SplashOnNCHitTest - handler for WM_NCHITTEST message
  470. //
  471. static UINT SplashOnNCHitTest(HWND hwnd, int x, int y)
  472. {
  473. // retrieve lpSplash from window extra bytes
  474. //
  475. LPSPLASH lpSplash = (LPSPLASH) GetWindowLongPtr(hwnd, 0);
  476. UINT uResult;
  477. // prevent the user from dragging the window
  478. // if SPLASH_NOMOVE flag is set
  479. //
  480. if (lpSplash->dwFlags & SPLASH_NOMOVE)
  481. uResult = FORWARD_WM_NCHITTEST(hwnd, x, y, DefWindowProc);
  482. else
  483. {
  484. POINT pt;
  485. RECT rc;
  486. // get current mouse cursor position relative to client area
  487. //
  488. pt.x = x;
  489. pt.y = y;
  490. ScreenToClient(lpSplash->hwndSplash, &pt);
  491. // if mouse cursor is within window client area
  492. // pretend it is actually within the title bar
  493. //
  494. GetClientRect(lpSplash->hwndSplash, &rc);
  495. if (PtInRect(&rc, pt))
  496. uResult = HTCAPTION;
  497. else
  498. uResult = FORWARD_WM_NCHITTEST(hwnd, x, y, DefWindowProc);
  499. }
  500. return uResult;
  501. }
  502. // SplashOnChar - handler for WM_CHAR message
  503. //
  504. static void SplashOnChar(HWND hwnd, UINT ch, int cRepeat)
  505. {
  506. BOOL fSuccess = TRUE;
  507. // retrieve lpSplash from window extra bytes
  508. //
  509. LPSPLASH lpSplash = (LPSPLASH) GetWindowLongPtr(hwnd, 0);
  510. // hide window if key pressed
  511. //
  512. if (SplashAbort(lpSplash) != 0)
  513. fSuccess = TraceFALSE(NULL);
  514. return;
  515. }
  516. // SplashOnLButtonDown - handler for WM_LBUTTONDOWN message
  517. //
  518. static void SplashOnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
  519. {
  520. BOOL fSuccess = TRUE;
  521. // retrieve lpSplash from window extra bytes
  522. //
  523. LPSPLASH lpSplash = (LPSPLASH) GetWindowLongPtr(hwnd, 0);
  524. // hide window if mouse clicked on window
  525. //
  526. if (SplashAbort(lpSplash) != 0)
  527. fSuccess = TraceFALSE(NULL);
  528. return;
  529. }
  530. // SplashOnRButtonDown - handler for WM_LBUTTONDOWN message
  531. //
  532. static void SplashOnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
  533. {
  534. BOOL fSuccess = TRUE;
  535. // retrieve lpSplash from window extra bytes
  536. //
  537. LPSPLASH lpSplash = (LPSPLASH) GetWindowLongPtr(hwnd, 0);
  538. // hide window if mouse clicked on window
  539. //
  540. if (SplashAbort(lpSplash) != 0)
  541. fSuccess = TraceFALSE(NULL);
  542. return;
  543. }
  544. // SplashAbort - hide splash window if SPLASH_ABORT flag set
  545. // <lpSplash> (i) pointer to SPLASH struct
  546. // return 0 if success
  547. //
  548. static int SplashAbort(LPSPLASH lpSplash)
  549. {
  550. BOOL fSuccess = TRUE;
  551. // hide window if SPLASH_ABORT flag set
  552. //
  553. if ((lpSplash->dwFlags & SPLASH_ABORT) &&
  554. lpSplash->fVisible &&
  555. SplashHide(SplashGetHandle(lpSplash)) != 0)
  556. fSuccess = TraceFALSE(NULL);
  557. return fSuccess ? 0 : -1;
  558. }
  559. // SplashGetPtr - verify that splash handle is valid,
  560. // <hSplash> (i) handle returned from SplashInit
  561. // return corresponding splash pointer (NULL if error)
  562. //
  563. static LPSPLASH SplashGetPtr(HSPLASH hSplash)
  564. {
  565. BOOL fSuccess = TRUE;
  566. LPSPLASH lpSplash;
  567. if ((lpSplash = (LPSPLASH) hSplash) == NULL)
  568. fSuccess = TraceFALSE(NULL);
  569. else if (IsBadWritePtr(lpSplash, sizeof(SPLASH)))
  570. fSuccess = TraceFALSE(NULL);
  571. #ifdef CHECKTASK
  572. // make sure current task owns the splash handle
  573. //
  574. else if (lpSplash->hTask != GetCurrentTask())
  575. fSuccess = TraceFALSE(NULL);
  576. #endif
  577. return fSuccess ? lpSplash : NULL;
  578. }
  579. // SplashGetHandle - verify that splash pointer is valid,
  580. // <lpSplash> (i) pointer to SPLASH struct
  581. // return corresponding splash handle (NULL if error)
  582. //
  583. static HSPLASH SplashGetHandle(LPSPLASH lpSplash)
  584. {
  585. BOOL fSuccess = TRUE;
  586. HSPLASH hSplash;
  587. if ((hSplash = (HSPLASH) lpSplash) == NULL)
  588. fSuccess = TraceFALSE(NULL);
  589. return fSuccess ? hSplash : NULL;
  590. }