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.

336 lines
9.2 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * WUCARET.C
  8. * WOW32 16-bit User API support
  9. *
  10. * History:
  11. * Created 07-Mar-1991 by Jeff Parsons (jeffpar)
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. MODNAME(wucaret.c);
  16. /*++
  17. void CreateCaret(<hwnd>, <hBitmap>, <nWidth>, <nHeight>)
  18. HWND <hwnd>;
  19. BITMAP <hBitmap>;
  20. int <nWidth>;
  21. int <nHeight>;
  22. The %CreateCaret% function creates a new shape for the system caret and
  23. assigns ownership of the caret to the given window. The caret shape can be a
  24. line, block, or bitmap as defined by the <hBitmap> parameter. If <hBitmap>
  25. is a bitmap handle, the <nWidth> and <nHeight> parameters are ignored; the
  26. bitmap defines its own width and height. (The bitmap handle must have been
  27. previously created by using the %CreateBitmap%, %CreateDIBitmap%, or
  28. %LoadBitmap% function.) If <hBitmap> is NULL or 1, <nWidth> and <nHeight>
  29. give the caret's width and height (in logical units); the exact width and
  30. height (in pixels) depend on the window's mapping mode.
  31. If <nWidth> or <nHeight> is zero, the caret width or height is set to the
  32. system's window-border width or height. Using the window-border width or
  33. height guarantees that the caret will be visible on a high-resolution
  34. display.
  35. The %CreateCaret% function automatically destroys the previous caret shape,
  36. if any, regardless of which window owns the caret. Once created, the caret
  37. is initially hidden. To show the caret, the %ShowCaret% function must be
  38. called.
  39. <hwnd>
  40. Identifies the window that owns the new caret.
  41. <hBitmap>
  42. Identifies the bitmap that defines the caret shape. If
  43. <hBitmap> is NULL, the caret is solid; if <hBitmap> is 1, the caret is
  44. gray.
  45. <nWidth>
  46. Specifies the width of the caret (in logical units).
  47. <nHeight>
  48. Specifies the height of the caret (in logical units).
  49. This function does not return a value.
  50. The system caret is a shared resource. A window should create a caret only
  51. when it has the input focus or is active. It should destroy the caret before
  52. losing the input focus or becoming inactive.
  53. The system's window-border width or height can be retrieved by using the
  54. %GetSystemMetrics% function with the SM_CXBORDER and SM_CYBORDER indexes.
  55. --*/
  56. ULONG FASTCALL WU32CreateCaret(PVDMFRAME pFrame)
  57. {
  58. register PCREATECARET16 parg16;
  59. HANDLE h32;
  60. GETARGPTR(pFrame, sizeof(CREATECARET16), parg16);
  61. h32 = (HANDLE)parg16->f2;
  62. // 0 -> caret is solid, 1 -> caret is gray, otherwise it's an hBitmap
  63. if(((DWORD)h32) > 1) {
  64. h32 = HBITMAP32(h32);
  65. }
  66. CreateCaret(HWND32(parg16->f1), h32, INT32(parg16->f3), INT32(parg16->f4));
  67. FREEARGPTR(parg16);
  68. RETURN(0);
  69. }
  70. /*++
  71. void DestroyCaret(VOID)
  72. The %DestroyCaret% function destroys the current caret shape, frees the
  73. caret from the window that currently owns it, and removes the caret from the
  74. screen if it is visible. The %DestroyCaret% function checks the ownership of
  75. the caret and destroys the caret only if a window in the current task owns
  76. it.
  77. If the caret shape was previously a bitmap, %DestroyCaret% does not free the
  78. bitmap.
  79. This function has no parameters.
  80. This function does not return a value.
  81. The caret is a shared resource. If a window has created a caret shape, it
  82. destroys that shape before it loses the input focus or becomes inactive.
  83. --*/
  84. ULONG FASTCALL WU32DestroyCaret(PVDMFRAME pFrame)
  85. {
  86. UNREFERENCED_PARAMETER(pFrame);
  87. DestroyCaret();
  88. RETURN(0);
  89. }
  90. /*++
  91. WORD GetCaretBlinkTime(VOID)
  92. The %GetCaretBlinkTime% function retrieves the caret blink rate. The blink
  93. rate is the elapsed time in milliseconds between flashes of the caret.
  94. This function has no parameters.
  95. The return value specifies the blink rate (in milliseconds).
  96. --*/
  97. ULONG FASTCALL WU32GetCaretBlinkTime(PVDMFRAME pFrame)
  98. {
  99. ULONG ul;
  100. UNREFERENCED_PARAMETER(pFrame);
  101. ul = GETWORD16(GetCaretBlinkTime());
  102. RETURN(ul);
  103. }
  104. /*++
  105. void GetCaretPos(<lpPoint>)
  106. LPPOINT <lpPoint>;
  107. The %GetCaretPos% function retrieves the caret's current position (in screen
  108. coordinates), and copies them to the %POINT% structure pointed to by the
  109. <lpPoint> parameter.
  110. <lpPoint>
  111. Points to the %POINT% structure that is to receive the screen coordinates
  112. of the caret.
  113. This function does not return a value.
  114. The caret position is always given in the client coordinates of the window
  115. that contains the caret.
  116. --*/
  117. ULONG FASTCALL WU32GetCaretPos(PVDMFRAME pFrame)
  118. {
  119. POINT t1;
  120. register PGETCARETPOS16 parg16;
  121. GETARGPTR(pFrame, sizeof(GETCARETPOS16), parg16);
  122. GetCaretPos(
  123. &t1
  124. );
  125. PUTPOINT16(parg16->f1, &t1);
  126. FREEARGPTR(parg16);
  127. RETURN(0);
  128. }
  129. /*++
  130. void HideCaret(<hwnd>)
  131. HWND <hwnd>;
  132. The %HideCaret% function hides the caret by removing it from the display
  133. screen. Although the caret is no longer visible, it can be displayed again
  134. by using the %ShowCaret% function. Hiding the caret does not destroy its
  135. current shape.
  136. The %HideCaret% function hides the caret only if the given window owns the
  137. caret. If the <hwnd> parameter is NULL, the function hides the caret only if
  138. a window in the current task owns the caret.
  139. Hiding is cumulative. If %HideCaret% has been called five times in a row,
  140. %ShowCaret% must be called five times before the caret will be shown.
  141. <hwnd>
  142. Identifies the window that owns the caret, or it is NULL to indirectly
  143. specify the window in the current task that owns the caret.
  144. This function does not return a value.
  145. --*/
  146. ULONG FASTCALL WU32HideCaret(PVDMFRAME pFrame)
  147. {
  148. register PHIDECARET16 parg16;
  149. GETARGPTR(pFrame, sizeof(HIDECARET16), parg16);
  150. HideCaret(
  151. HWND32(parg16->f1)
  152. );
  153. FREEARGPTR(parg16);
  154. RETURN(0);
  155. }
  156. /*++
  157. void SetCaretBlinkTime(<wMSeconds>)
  158. WORD <wMSeconds>;
  159. The %SetCaretBlinkTime% function sets the caret blink rate (elapsed time
  160. between caret flashes) to the number of milliseconds specified by the
  161. <wMSeconds> parameter. The caret flashes on or off each <wMSeconds>
  162. milliseconds. This means one complete flash (on-off-on) takes 2 x
  163. <wMSeconds> milliseconds.
  164. <wMSeconds>
  165. Specifies the new blink rate (in milliseconds).
  166. This function does not return a value.
  167. The caret is a shared resource. A window should set the caret blink rate
  168. only if it owns the caret. It should restore the previous rate before it
  169. loses the input focus or becomes inactive.
  170. --*/
  171. ULONG FASTCALL WU32SetCaretBlinkTime(PVDMFRAME pFrame)
  172. {
  173. register PSETCARETBLINKTIME16 parg16;
  174. GETARGPTR(pFrame, sizeof(SETCARETBLINKTIME16), parg16);
  175. SetCaretBlinkTime(
  176. WORD32(parg16->f1)
  177. );
  178. FREEARGPTR(parg16);
  179. RETURN(0);
  180. }
  181. /*++
  182. void SetCaretPos(<X>, <Y>)
  183. int <X>;
  184. int <Y>;
  185. The %SetCaretPos% function moves the caret to the position given by logical
  186. coordinates specified by the <X> and <Y> parameters. Logical coordinates are
  187. relative to the client area of the window that owns them and are affected by
  188. the window's mapping mode, so the exact position in pixels depends on this
  189. mapping mode.
  190. The %SetCaretPos% function moves the caret only if it is owned by a window
  191. in the current task. %SetCaretPos% moves the caret whether or not the caret
  192. is hidden.
  193. <X>
  194. Specifies the new x-coordinate (in logical coordinates) of the caret.
  195. <Y>
  196. Specifies the new <y>-coordinate (in logical coordinates) of the
  197. caret.
  198. This function does not return a value.
  199. The caret is a shared resource. A window should not move the caret if it
  200. does not own the caret.
  201. --*/
  202. ULONG FASTCALL WU32SetCaretPos(PVDMFRAME pFrame)
  203. {
  204. register PSETCARETPOS16 parg16;
  205. GETARGPTR(pFrame, sizeof(SETCARETPOS16), parg16);
  206. SetCaretPos(
  207. INT32(parg16->f1),
  208. INT32(parg16->f2)
  209. );
  210. FREEARGPTR(parg16);
  211. RETURN(0);
  212. }
  213. /*++
  214. void ShowCaret(<hwnd>)
  215. The %ShowCaret% function shows the caret on the display at the caret's
  216. current position. Once shown, the caret begins flashing automatically.
  217. The %ShowCaret% function shows the caret only if it has a current shape and
  218. has not been hidden two or more times in a row. If the caret is not owned by
  219. the given window, the caret is not shown. If the <hwnd> parameter is NULL,
  220. the %ShowCaret% function shows the caret only if it is owned by a window in
  221. the current task.
  222. Hiding the caret is accumulative. If the %HideCaret% function has been
  223. called five times in a row, %ShowCaret% must be called five times to show
  224. the caret.
  225. <hwnd>
  226. Identifies the window that owns the caret, or is NULL to specify
  227. indirectly the owner window in the current task.
  228. This function does not return a value.
  229. The caret is a shared resource. A window should show the caret only when it
  230. has the input focus or is active.
  231. --*/
  232. ULONG FASTCALL WU32ShowCaret(PVDMFRAME pFrame)
  233. {
  234. register PSHOWCARET16 parg16;
  235. GETARGPTR(pFrame, sizeof(SHOWCARET16), parg16);
  236. ShowCaret(
  237. HWND32(parg16->f1)
  238. );
  239. FREEARGPTR(parg16);
  240. RETURN(0);
  241. }