Source code of Windows XP (NT5)
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.

314 lines
11 KiB

  1. NOTE: This DLL is the same as that shipped with the OLE 2.0 SDK
  2. but is updated from that shipped with "The Windows Interface" book
  3. from Microsoft Press. It is now compatible with Windows NT.
  4. ----------
  5. Changes in BTTNCUR.DLL Source Code and Documentation from Version 1.00b
  6. to Version 1.1. See also below for 1.00 to 1.00b changes.
  7. BTTNCUR.DLL version 1.1 is now fully compatible and tested under Windows
  8. 3.0. Previously the demo application crashed under Windows 3.0
  9. on calls to the non-existent MoveToEx (Win32 compatible). Version 1.1 only
  10. uses MoveToEx for builds where the symbol WINVER < 0x030a.
  11. Windows NT changes are surrounded by #ifdef WIN32. The largest change
  12. is the DLL entry point: LibMain. Both Win3.1 and Win32 versions
  13. call FInitialize now.
  14. The images have been updated slightly and are now provided for 72dpi
  15. (ega), 96dpi (vga), and 120dpi (super vga)
  16. Version 1.1 completely handles system color changes unlike version 1.00x.
  17. This new version will dynamically convert black, light gray, dark gray,
  18. and white pixels in the image bitmap into system colors set for the
  19. button text, button shadow, button face, and button highlight, respectively.
  20. If you have blue, red, yellow, and green button colors, BTTNCUR.DLL will
  21. now work perfectly with all of them.
  22. BTTNCUR.DLL Version 1.1 also supports color images better by allowing
  23. you to control which colors in the image bitmap are converted to system
  24. colors. By default, any black, gray, or white colors are converted
  25. into system button colors as decribed in the last paragraph. BTTNCUR.H
  26. defines new PRESERVE_* flags for each of the four colors that are liable
  27. to be converted. By specifing one or more flags you prevent BTTNCUR
  28. from changing that color to a system color. For example, if you
  29. want to preserve all black pixels in your image, specify PRESERVE_BLACK
  30. when calling UIToolButtonDraw.
  31. Applications should obtain configuration data for the current display
  32. through UIToolConfigureForDisplay. With this data the application can
  33. configure itself for the correct toolbar size and button sizes and load
  34. the appropriate application supplied bitmaps.
  35. Applications using UIToolConfigureForDisplay should now use
  36. UIToolButtonDrawTDD instead of UIToolButtonDraw, passing one extra
  37. parameter, a pointer to the TOOLDISPLAYDATA. Applications that
  38. still call UIToolButtonDraw will always use 96dpi.
  39. ------------------------
  40. BTTNCUR.H changes
  41. Added PRESERVE_ flags to allow application to control color conversions
  42. from black, dark gray, light gray, and white into the
  43. file compatible with C++.
  44. Added prototype for UIToolConfigureForDisplay, TOOLDISPLAYDATA structure,
  45. and definitions for button and image sizes on 72dpi, 96dpi, and 120dpi.
  46. ------------------------
  47. BTTNCUR.RCV version changes
  48. FILEVERSION and PRODUCTVERSION changed from 1,0,0,2 to 1,0,1,0
  49. VALUE "FileVersion" and VALUE "ProductVersion" changed from
  50. "1.00b\0","\0" to "1.1\0","\0"
  51. ------------------------
  52. BTTNCURI.H changes
  53. Defined STDCOLOR_* values as indices into an array in BTTNCUR.C
  54. that holds hard-coded default button color that never change
  55. regardless of the system colors. Also defined SYSCOLOR_*
  56. flags that matched STDCOLOR_* flags for uniform array indices.
  57. Removed NEAR, FAR, and PASCAL from any function that didn't need it
  58. so we can port to Windows NT cleanly.
  59. ------------------------
  60. BTTNCUR.C source code changes. There are significant modifications.
  61. Overall:
  62. Updated header comment
  63. Removed NEAR, FAR, and PASCAL from any function that didn't need it
  64. so we can port to Windows NT cleanly.
  65. Globals:
  66. Eliminated the COLORREFs prefixed with RGB. Only a few are needed
  67. statically and were moved to HBrushDitherCreate.
  68. Also added an array of standard colors used in the standard images:
  69. static const
  70. COLORREF crStandard[4]={ RGB(0, 0, 0) //STDCOLOR_BLACK
  71. , RGB(128, 128, 128) //STDCOLOR_DKGRAY
  72. , RGB(192, 192, 192) //STDCOLOR_LTGRAY
  73. , RGB(255, 255, 255)}; //STDCOLOR_WHITE
  74. Added an array of standard images instead of just 96dpi versions.
  75. UIToolConfigureForDisplay:
  76. Added function to return the resolution of the display and
  77. size information about button and image sizes.
  78. ToolButtonInit():
  79. Call to CreatePatternBrush moved into HBrushDitherCreate.
  80. Conditionally sets the highlight color for HDitherBrushCreate
  81. depending on Windows 3.x or Windows 3.0 (3.0 did not support
  82. COLOR_BTNHIGHLIGHT).
  83. ToolButtonFree():
  84. Removed some old debug output no longer useful.
  85. HDitherBitmapCreate()
  86. Renamed to HBrushDitherCreate.
  87. Moved CreatePatterBrush code from ToolButtonInit into this
  88. function.
  89. To support changing system colors, this function maintains
  90. static variables for the face and highlight colors that we
  91. use to create the brush. If the function is called and the
  92. current colors in the global hBrushDither are different than
  93. the system colors, we recreate the brush and update the global
  94. hBrushDither, deleting the old brush. Otherwise we just return
  95. hBrushDither.
  96. Note that if we fail to create the new brush we just maintain
  97. the old. We'll paint something, albeit not in the right colors,
  98. but something nontheless.
  99. UIToolButtonDraw():
  100. Calls UIToolButtonDrawTDD with default display configuration.
  101. UIToolButtonDrawTDD():
  102. This is the function that was overhauled the most, specifically
  103. to handle variable colors.
  104. First, we added several local variables of which two are important.
  105. crSys is an array of system colors for the text, shadow, face,
  106. highlight, and frame, declared as static to keep references to
  107. it off DS instead of SS; if it's in SS things will crash. The second
  108. important variable is uColor, which receives the color preservation
  109. flags passed in the hibyte of the uState parameter to UIToolButtonDraw.
  110. All the code to draw a blank button outline was moved into a separate
  111. function DrawBlankButton. Since this procedure needs all the system
  112. colors to do it's thing, I've set it up to take an array of five
  113. COLORREFs (exactly crSys) in which it stores those color (it also
  114. uses it as its color variables). This way we only have to call
  115. GetSysColor once for each system color.
  116. Anything dealing with the dithered brush is moved to the
  117. BUTTONGROUP_LIGHTFACE case where we just get the current brush
  118. by calling HBrushDitherCreate, passing it the current face
  119. and highlight colors. Remember that is these colors match those
  120. used in the currently held global hBrushDither, this function just
  121. returns that global, so it's quite fast. We have to be very careful
  122. not to delete this brush where we're done with it since it is global.
  123. The largest amount of new code is under the line:
  124. if ((uState & BUTTONGROUP_ACTIVE) && !(uState & BUTTONGROUP_BLANK))
  125. This has changed from a single BitBlt call to a much more complex
  126. operation to handle specific color conversions and preservations.
  127. A little optimization was done to detect when the system colors
  128. for buttons match the defaults, that is, black, dark gray, light gray,
  129. and white for text, shadow, face, and highlight. If these colors
  130. all match, or if the caller requested preservation of all colors,
  131. the we just do the single BitBlt of old.
  132. Otherwise we loop through each of the black/white/gray colors
  133. that need possible conversion. For each one we create a mask
  134. that contains 1's where the converting color exists in the image
  135. and 0's everywhere else. For each color then we BitBlt the
  136. mask, a brush matching the system color we're converting to,
  137. and the destination bitmap (which we initialize with the unmodified
  138. image itself) using ROP_DSPDxax. This leaves any color but the
  139. one under conversion alone and replaces the converted color with
  140. the system color.
  141. If the caller set a specific flag to preserve one or more specific
  142. colors, then we replace the standard color with the standard color,
  143. resulting in a no-op.
  144. Finally, to reduce flicker for this four Blt operation we create
  145. and build the final image in a temporary bitmap, making it 6 total
  146. Blts to handle the color changes. But since we optimized for the
  147. 99% case where the system colors are the standard colors, this isn't
  148. too much of a consideration.
  149. color conversions.
  150. DrawBlankButton():
  151. New internal function. Moved code from UIToolButtonDraw here.
  152. ------------------------
  153. CURSORS.C
  154. Updated header comment
  155. Removed PASCAL on both internal functions.
  156. CursorsFree
  157. Eliminated all the code inside this function as it was unnecessary.
  158. UICursorLoad
  159. Eliminated code to revalidate a cursor in the array. Unnecessary.
  160. ------------------------
  161. BCDEMO.C
  162. Tested for running under Windows 3.0 and avoided MoveToEx calls,
  163. using MoveTo instead. Calling MoveToEx in a Windows 3.1 app
  164. marked as 3.0 compatible under 3.0 causes an unknown GP fault.
  165. Uses UIToolButtonConfigureForDisplay and UIToolButtonDrawTDD.
  166. ------------------------------------------------------------------------------
  167. Changes in BTTNCUR.DLL Source Code and Documentation from Version 1.00
  168. to Version 1.00b
  169. ------------------------
  170. BTTNCUR.H changes
  171. Added #ifdef __cplusplus to include extern "C" making the
  172. file compatible with C++.
  173. ------------------------
  174. BTTNCURI.H changes
  175. Added #ifdef __cplusplus to include extern "C" making the
  176. file compatible with C++.
  177. Removed code contained between a #ifdef NEVER that is unused.
  178. ------------------------
  179. BTTNCUR.RCV version changes
  180. FILEVERSION and PRODUCTVERSION changed from 1,0,0,0 to 1,0,0,2
  181. VALUE "FileVersion" and VALUE "ProductVersion" changed from
  182. "1.00\0","\0" to "1.00b\0","\0"
  183. ------------------------
  184. BTTNCUR.C source code changes.
  185. Added a global for the frame color
  186. static COLORREF rgbFrame =RGB(0, 0, 0);
  187. WEP():
  188. Added comment about resource cleanup messages in DEBUG mode.
  189. ToolButtonInit():
  190. Added the line below just before the assignment of hDCGlyphs:
  191. rgbFrame=GetSysColor(COLOR_WINDOWFRAME);
  192. This insures that the frame color is properly shown on plasma
  193. displays.
  194. ToolButtonFree():
  195. Added the following lines just before return:
  196. if (NULL!=hBmpStandardImages)
  197. DeleteObject(hBmpStandardImages);
  198. hBmpStandardImages=NULL;
  199. UIToolButtonDraw():
  200. The image centering is one too high. The line
  201. yOffsetGlyph=((dy-bmy) >> 1)-1;
  202. now reads:
  203. yOffsetGlyph=(dy-bmy) >> 1;
  204. The declaration HBITMAP hBmp; now read HBITMAP hBmp=NULL;
  205. The line hBmpT=SelectObject(hDCGlyphs, hBmp); is now two:
  206. if (NULL!=hBmp)
  207. SelectObject(hDCGlyphs, hBmp);
  208. The line SelectObject(hDCGlyphs, hBmpT); is now two:
  209. if (NULL!=hBmpT)
  210. SelectObject(hDCGlyphs, hBmpT);
  211. ------------------------
  212. BTTNCUR.BMP
  213. Fixed the images to be 16*15 (the standard) instead of 16*16
  214. as they originally were. Changed the label "16x16" to "16x15".
  215. Copied an image of the disabled state of Context-Sensitive Help
  216. to this bitmap as it was previously missing.