Desktop Functions: Smart Device Functions:
|
CreateCaret (user32)
C# Signature:
[DllImport("user32.dll")] VB.NET:
<DllImport("user32.dll")> _ User-Defined Types:None. Notes:Windows allows only one caret per message queue. To add a caret to a control, handle the WM_SETFOCUS message, or the GotFocus event, or override OnGotFocus if you're writing a custom control, and call CreateCaret from the message or event handler. You should also handle WM_KILLFOCUS, LostFocus or OnLostFocus and call DestroyCaret. You will also need to call ShowCaret to make the caret visible, and SetCaretPos to set its position. Tips & Tricks:If you're using a Bitmap image to render the caret, the colour will be changed based on the background of the Control. To ensure that you have the expected colour, first apply an XOR mask:
int r = CursorColour.R ^ ParentControl.BackColor.R; Where CursorColour is the colour you would like the caret to have and ParentControl is the control that the caret is bound to. Sample Code://C# Example. This will create and show the caret in textBox1 when button1 is clicked.
private void button1_Click(object sender, System.EventArgs e) { Alternative Managed API:Do you know one? Please contribute it! Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|