dcsimg
December 7, 2016
Hot Topics:

Using Carets

  • November 19, 2002
  • By Scott Lloyd
  • Send Email »
  • More Articles »

Computers multitask, humans do not. Because of this a user can only focus on editing one part of a document at a time. Since the caret is used to tell a user where he is in the document, it makes since that you can only allocate one caret per application. This is actually a good thing because this way we don't have to keep track of handles nor will we be forced to supply handles to every call to clarify on which caret the operation is to be performed.

To create a caret one must call the CreateCaret function. Like most things that an application allocates via the API, the caret must be destroyed before your application terminates. Destruction of a caret created with CreateCaret is done by a call to the DestroyCaret function.

Public Declare Function CreateCaret Lib "User32" _
(ByVal hWnd As Long, ByVal hBitmap As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long

Public Declare Function DestroyCaret _
Lib "User32" () As Long

Carets come in all sorts of shapes and sizes. You can specify how the caret should look in the creation process. Carets can be the common blinking line that we've all come to know and love, a block cursor, or even a bitmap. The height and width arguments to CreateCaret determine the size of the caret, suprisingly enough. Don't worry about positioning yet as that is done with another function that we will cover later. The bitmap argument is a handle to a bitmap. Since bitmaps are rarely used as carets that topic won't be discussed here but you can find all the information you want by digging up a few documents on the Windows bitmap API.





Page 2 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel