HOWTO: Create a Nonblinking Caret
ID: Q74607
|
The information in this article applies to:
-
Microsoft Win32 Software Development Kit (SDK)
-
Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1
-
Microsoft Windows 2000
SUMMARY
The Microsoft Windows graphical environment is designed to provide a
blinking caret. However, using a timer and the SetCaretBlinkTime()
function, an application can "trick" the caret into not blinking.
Applications should not arbitrarily change the caret blink time and respect the setting that the user has chosen.
If you change the blink time, subsequently activated applications will use the modified blink time, even if you restore the previous blink time when you lose the keyboard focus or become inactive. This is due to the multithreaded environment, where deactivation of your application is not synchronized with the activation of another application. This feature allows the system to activate another application even if the current application is hung.
MORE INFORMATION
Although Windows is designed to blink the caret at a specified interval, a
timer function and SetCaretBlinkTime() can be used to prevent Windows from
turning the caret off by following these three steps:
- Call SetCaretBlinkTime(10000), which instructs Windows to blink the
caret every 10,000 milliseconds (10 seconds). This results in a
"round-trip" time of 20 seconds to go from OFF to ON and back to
OFF (or vice versa).
- Create a timer, using SetTimer(), specifying a timer procedure and a
5,000 millisecond interval between timer ticks.
- In the timer procedure, call SetCaretBlinkTime(10000). This resets
the timer in Windows that controls the caret blink.
When an application implements this procedure, Windows never removes the
caret from the screen, and the caret does not blink.
Additional query words:
WIN16SDK
Keywords : kbCaret kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS
Version : WINDOWS:3.0,3.1
Platform : WINDOWS
Issue type : kbhowto