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.

227 lines
5.7 KiB

  1. /****************************************************************************
  2. *
  3. * Bmp.C
  4. *
  5. * Microsoft Confidential
  6. * Copyright (c) Microsoft Corporation 1992-1993
  7. * All rights reserved
  8. *
  9. * Deals with painting bitmaps on the wizard pages
  10. * FelixA 1994.
  11. ***************************************************************************/
  12. #include <windows.h>
  13. #include "bmp.h"
  14. //***************************************************************************
  15. //
  16. // BMP_RegisterClass()
  17. // Registers the bitmap control class
  18. //
  19. // ENTRY:
  20. // hInstance
  21. //
  22. // EXIT:
  23. // NONE currently.
  24. //
  25. //***************************************************************************
  26. BOOL FAR PASCAL BMP_RegisterClass(HINSTANCE hInstance)
  27. {
  28. WNDCLASS wc;
  29. if (!GetClassInfo(hInstance, SU_BMP_CLASS, &wc)) {
  30. wc.lpszClassName = SU_BMP_CLASS;
  31. wc.style = 0;
  32. wc.lpfnWndProc = BMP_WndProc;
  33. wc.hInstance = hInstance;
  34. wc.hIcon = NULL;
  35. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  36. wc.hbrBackground = NULL;
  37. wc.lpszMenuName = NULL;
  38. wc.cbClsExtra = 0;
  39. wc.cbWndExtra = 5*sizeof(WORD);
  40. if (!RegisterClass(&wc))
  41. return FALSE;
  42. }
  43. return TRUE;
  44. }
  45. //***************************************************************************
  46. //
  47. // BMP_DestroyClass()
  48. // Draws the bitmap control.
  49. //
  50. // ENTRY:
  51. // hInstance
  52. //
  53. // EXIT:
  54. // NONE currently.
  55. //
  56. //***************************************************************************
  57. void FAR PASCAL BMP_DestroyClass( HINSTANCE hInst )
  58. {
  59. WNDCLASS wndClass;
  60. if( GetClassInfo(hInst, SU_BMP_CLASS, &wndClass) )
  61. if( !FindWindow( SU_BMP_CLASS, NULL ) )
  62. UnregisterClass(SU_BMP_CLASS, hInst);
  63. }
  64. //***************************************************************************
  65. //
  66. // BMP_Draw()
  67. // Draws the bitmap control.
  68. //
  69. // ENTRY:
  70. // NONE
  71. //
  72. // EXIT:
  73. // NONE currently.
  74. //
  75. //***************************************************************************
  76. void FAR PASCAL BMP_Paint(HWND hwnd)
  77. {
  78. PAINTSTRUCT ps;
  79. HDC hdc, hdcMem;
  80. int idBmp;
  81. HBITMAP hbm, hbmOld;
  82. HBRUSH hbrOld;
  83. HINSTANCE hInst;
  84. int iDeleteBmp=TRUE;
  85. BITMAP bm;
  86. // For independence.
  87. idBmp = GetDlgCtrlID( hwnd );
  88. hInst = (HINSTANCE)GetWindowWord( hwnd, GWW_HINSTANCE );
  89. // Paint.
  90. hdc = BeginPaint(hwnd,&ps);
  91. hbm = LoadBitmap(hInst, MAKEINTRESOURCE(idBmp));
  92. if (hbm)
  93. {
  94. GetObject(hbm, sizeof(bm), &bm);
  95. hdcMem = CreateCompatibleDC(hdc);
  96. hbmOld = SelectObject(hdcMem, hbm);
  97. // Draw the bitmap
  98. BitBlt(hdc, 0, 0, bm.bmWidth , bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
  99. // Draw a frame around it.
  100. hbrOld = SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
  101. Rectangle( hdc, 0, 0, bm.bmWidth, bm.bmHeight );
  102. SelectObject(hdc, hbrOld);
  103. SelectObject(hdcMem, hbmOld);
  104. DeleteObject(hbm);
  105. DeleteDC(hdcMem);
  106. }
  107. EndPaint(hwnd,(LPPAINTSTRUCT)&ps);
  108. }
  109. // ****************************************************************************
  110. //
  111. // BMP_WndProc()
  112. // This routine handles all the message for the bitmap control.
  113. //
  114. // ENTRY:
  115. // hWnd - Progress window handle.
  116. // wMsg - Message.
  117. // wParam - Message wParam data.
  118. // lParam - Message lParam data.
  119. //
  120. // EXIT:
  121. // Returns depends on message being processed.
  122. //
  123. // NOTES:
  124. // None.
  125. //
  126. // ***************************************************************************/
  127. LRESULT CALLBACK BMP_WndProc( HWND hWnd, UINT wMsg, WORD wParam, LONG lParam )
  128. {
  129. switch (wMsg)
  130. {
  131. // case WM_NCCREATE:
  132. // dw = GetWindowLong( hWnd,GWL_STYLE );
  133. // SetWindowLong( hWnd, GWL_STYLE, dw | WS_BORDER );
  134. // return TRUE;
  135. case WM_PAINT:
  136. BMP_Paint( hWnd );
  137. return 0L;
  138. }
  139. return DefWindowProc( hWnd, wMsg, wParam, lParam );
  140. }
  141. #if 0
  142. // Cached?
  143. //***************************************************************************
  144. //
  145. // zzzBMP_CacheBitmaps()
  146. // Loads and caches the bitmaps for setup
  147. //
  148. // NOTES:
  149. // You must free the bitmaps using zzzBMP_FreeBitmaps
  150. //
  151. //***************************************************************************
  152. typedef struct tag_Bitmap
  153. {
  154. int iBmp;
  155. HBITMAP hBmp;
  156. } BMPCACHE;
  157. static BMPCACHE BmpCache[] = { {IDB_WIZARD_NET, 0},
  158. {IDB_WIZARD_SETUP, 0},
  159. {0,0} };
  160. VOID FAR PASCAL zzzBMP_CacheBitmaps( )
  161. {
  162. int i=0;
  163. while( BmpCache[i].iBmp )
  164. BmpCache[i++].hBmp = LoadBitmap(hinstExe, MAKEINTRESOURCE(BmpCache[i].iBmp));
  165. }
  166. //***************************************************************************
  167. //
  168. // zzzBMP_FreeBitmapCache()
  169. // Frees the cache of the bitmaps
  170. //
  171. // NOTES:
  172. // Uses IDS_MB to actually format this string.
  173. //
  174. //***************************************************************************
  175. VOID FAR PASCAL zzzBMP_FreeBitmapCache( )
  176. {
  177. int i=0;
  178. while( BmpCache[i].iBmp )
  179. {
  180. if( BmpCache[i].hBmp && DeleteObject(BmpCache[i].hBmp) )
  181. BmpCache[i].hBmp = 0;
  182. i++;
  183. }
  184. }
  185. //***************************************************************************
  186. //
  187. // zzzBMP_LoadCachedBitmaps()
  188. // Returns the HBMP for the iBitmap you wanted.
  189. //
  190. // NOTES:
  191. // Uses IDS_MB to actually format this string.
  192. //
  193. //***************************************************************************
  194. HBITMAP FAR PASCAL zzzBMP_LoadCachedBitmaps(int iBitmap)
  195. {
  196. int i=0;
  197. while( BmpCache[i].iBmp )
  198. {
  199. if( BmpCache[i].iBmp == iBitmap )
  200. return BmpCache[i].hBmp;
  201. i++;
  202. }
  203. SU_TRAP
  204. return 0;
  205. }
  206. #endif