|
Hiding a Caret
Whenever your application redraws a screen while processing a message other
than WM_PAINT, it must make the caret invisible by using the HideCaret function. When your application is finished drawing, redisplay the caret by
using the ShowCaret function. If your application processes the WM_PAINT message, it is not
necessary to hide and redisplay the caret, because this function does this
automatically.
The following code sample shows how to have your application hide the caret
while drawing a character on the screen and while processing the WM_CHAR message.
HWND hwnd, // window handle
HDC hdc; // device context
case WM_CHAR:
switch (wParam)
{
case 0x08:
.
. // Process a backspace.
.
break;
case 0x09:
.
. // Process a tab.
.
break;
case 0x0D:
.
. // Process a carriage return.
.
break;
case 0x1B:
.
. // Process an escape.
.
break;
case 0x0A:
.
. // Process a linefeed.
.
break;
default:
// Hide the caret.
HideCaret(hwnd);
// Draw the character on the screen.
hdc = GetDC(hwnd);
SelectObject(hdc,
GetStockObject(SYSTEM_FIXED_FONT));
TextOut(hdc, x, y, lpszChar, 1);
ReleaseDC(hwnd, hdc);
// Display the caret.
ShowCaret(hwnd);
}
If your application calls the HideCaret function several times without calling ShowCaret, the caret will not be displayed until the application also calls ShowCaret the same number of times.
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|