4 * Copyright 1993 David Metcalfe
7 static char Copyright[] = "Copyright David Metcalfe, 1993";
27 static BOOL LockCaret;
29 static WORD CARET_Callback(HWND hwnd, WORD msg, WORD timerid, LONG ctime);
30 static void CARET_HideCaret();
33 /*****************************************************************
37 static WORD CARET_Callback(HWND hwnd, WORD msg, WORD timerid, LONG ctime)
44 printf("CARET_Callback: id=%d: LockCaret=%d, hidden=%d, on=%d\n",
45 timerid, LockCaret, Caret.hidden, Caret.on);
47 if (!LockCaret && (!Caret.hidden || Caret.on))
49 Caret.on = (Caret.on ? FALSE : TRUE);
50 hdc = GetDC(Caret.hwnd);
51 if (Caret.bitmap == 0 || Caret.bitmap == 1)
52 hBrush = CreateSolidBrush(Caret.color);
54 hBrush = CreatePatternBrush(Caret.bitmap);
55 SelectObject(hdc, (HANDLE)hBrush);
56 SetROP2(hdc, R2_XORPEN);
57 rgn = CreateRectRgn(Caret.x, Caret.y,
58 Caret.x + Caret.width,
59 Caret.y + Caret.height);
60 FillRgn(hdc, rgn, hBrush);
61 DeleteObject((HANDLE)rgn);
62 DeleteObject((HANDLE)hBrush);
63 ReleaseDC(Caret.hwnd, hdc);
69 /*****************************************************************
73 static void CARET_HideCaret()
80 hdc = GetDC(Caret.hwnd);
81 if (Caret.bitmap == 0 || Caret.bitmap == 1)
82 hBrush = CreateSolidBrush(Caret.color);
84 hBrush = CreatePatternBrush(Caret.bitmap);
85 SelectObject(hdc, (HANDLE)hBrush);
86 SetROP2(hdc, R2_XORPEN);
87 rgn = CreateRectRgn(Caret.x, Caret.y,
88 Caret.x + Caret.width,
89 Caret.y + Caret.height);
90 FillRgn(hdc, rgn, hBrush);
91 DeleteObject((HANDLE)rgn);
92 DeleteObject((HANDLE)hBrush);
93 ReleaseDC(Caret.hwnd, hdc);
97 /*****************************************************************
98 * CreateCaret (USER.163)
101 void CreateCaret(HWND hwnd, HBITMAP bitmap, short width, short height)
106 /* if cursor already exists, destroy it */
110 if (bitmap && bitmap != 1)
111 Caret.bitmap = bitmap;
116 Caret.width = GetSystemMetrics(SM_CXBORDER);
119 Caret.height = height;
121 Caret.height = GetSystemMetrics(SM_CYBORDER);
129 Caret.color = GetSysColor(COLOR_GRAYTEXT);
131 Caret.color = GetSysColor(COLOR_WINDOWTEXT);
135 Caret.timerid = SetSystemTimer(NULL, 0, Caret.timeout, CARET_Callback);
138 printf("CreateCaret: hwnd=%d, timerid=%d\n", hwnd, Caret.timerid);
143 /*****************************************************************
144 * DestroyCaret (USER.164)
149 /* if (!Caret.hwnd) return;
152 printf("DestroyCaret: timerid\n", Caret.timerid);
155 KillSystemTimer(NULL, Caret.timerid);
160 Caret.hwnd = 0; /* cursor marked as not existing */
164 /*****************************************************************
165 * SetCaretPos (USER.165)
168 void SetCaretPos(short x, short y)
174 if (!Caret.hwnd) return;
177 printf("SetCaretPos: x=%d, y=%d\n", x, y);
189 /*****************************************************************
190 * HideCaret (USER.166)
193 void HideCaret(HWND hwnd)
195 if (!Caret.hwnd) return;
196 if (hwnd && (Caret.hwnd != hwnd)) return;
207 /*****************************************************************
208 * ShowCaret (USER.167)
211 void ShowCaret(HWND hwnd)
213 if (!Caret.hwnd) return;
214 if (hwnd && (Caret.hwnd != hwnd)) return;
217 printf("ShowCaret: hidden=%d\n", Caret.hidden);
224 /*****************************************************************
225 * SetCaretBlinkTime (USER.168)
228 void SetCaretBlinkTime(WORD msecs)
230 if (!Caret.hwnd) return;
232 KillSystemTimer(NULL, Caret.timerid);
233 Caret.timeout = msecs;
234 Caret.timerid = SetSystemTimer(NULL, 0, Caret.timeout, CARET_Callback);
238 /*****************************************************************
239 * GetCaretBlinkTime (USER.169)
242 WORD GetCaretBlinkTime()
244 if (!Caret.hwnd) return;
246 return Caret.timeout;
250 /*****************************************************************
251 * GetCaretPos (USER.183)
254 void GetCaretPos(LPPOINT pt)
256 if (!Caret.hwnd || !pt) return;