Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RTB Carets

Status
Not open for further replies.

GTO

Programmer
Jul 11, 2000
40
0
0
US
Can anyone tell me why, given I have the createcaret
api in a bas module, the following code does not create a block caret. I've tried this code in keypress and keydown. Neither worked, no error messages.


h& = GetFocus&()
Call CreateCaret(h&, 0, 5, 15)
m& = ShowCaret&(h&)


The only key to give the block is the insert key.
I am speaking of a line which has text on it. So if I click in the middle of said line, & hit insert, I want to be in insert mode with a blocked caret.
Hitting any key other than insert turns the block back off, why?
Typeing on a blank line doesn't!
Is there any way to make this work the way I want?
Also, if there is, to make the block proportional to the type size.

Thanks in advance
Clyde Saye



 
Change The Caret Of A Text Box

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 2 Text Boxes and 1 PictureBox to your form. Add BMP Picture to the Picture Box.
'This Picture will be Text1 Caret.
'Insert this code to the module :

Declare Function CreateCaret Lib "user32" (ByVal hwnd As Long, _
ByVal hBitmap As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function ShowCaret Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetFocus Lib "user32" () As Long

'Insert this code to your form:

Private Sub Text1_GotFocus()
h& = GetFocus&()
b& = Picture1.Picture
Call CreateCaret(h&, b&, 10, 10)
X& = ShowCaret&(h&)
End Sub

Private Sub Text2_GotFocus()
h& = GetFocus&()
'The '25' below is the Caret Width. The '30' Below is the Caret High
Call CreateCaret(h&, 0, 25, 30)
X& = ShowCaret&(h&)
End Sub


Eric De Decker
vbg.be@vbgroup.nl

License And Copy Protection AxtiveX.

Download Demo version on my Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top