[lazarus] Need your thoughts on Caret

Micha Nelissen M.Nelissen at student.tue.nl
Mon Aug 11 17:11:03 EDT 2003


Mattias Gaertner wrote:

> On Mon, 11 Aug 2003 20:56:52 +0200
> Micha Nelissen <M.Nelissen at student.tue.nl> wrote:
> 
> 
>>Hi,
>>
>>The SynEdit creates a caret to display. This is implemented in the win32 
>>interface, but the win32 interface needs it to be created on *every* 
>>setfocus. That is, when you lose focus, you hide & destroy your caret, 
>>then when you get focus, you need to create & show the caret. Help from 
>>win32sdk on ShowCaret:
>>
>><snip>
>>ShowCaret shows the caret only if the specified window owns the caret, 
>>the caret has a shape, and the caret has not been hidden two or more 
>>times in a row. If one or more of these conditions is not met, ShowCaret 
>>does nothing and returns FALSE.
>></snip>
> 

The documentation is vague, but this is what I make of it:

> What do "the specified window owns the caret" 

You've called CreateCaret recently enough.

> and "the caret has a shape" mean?

The CreateCaret call was succesfull and you've supplied the same window 
to CreateCaret as ShowCaret. It seems to do these both things at once.

<snip>
The CreateCaret function creates a new shape for the system caret and 
assigns ownership of the caret to the specified window. The caret shape 
can be a line, a block, or a bitmap.

CreateCaret automatically destroys the previous caret shape, if any, 
regardless of the window that owns the caret. The caret is hidden until 
the application calls the ShowCaret function to make the caret visible.

The caret is a shared resource; there is only one caret in the system. A 
window should create a caret only when it has the keyboard focus or is 
active. The window should destroy the caret before losing the keyboard 
focus or becoming inactive.
</snip>

>>If you trace code flow you will see that ShowCaret indeed returns false 
>>most of the time if not always.
>>
>>Since this involves more than simply adjusting the win32 interface, I 
>>ask for your thoughts on this.
> 
> 
> You mean, changing the synedit code?
> The caret showing code in synedit has not much changed for the LCL. Does the
> synedit1 example work under win32 intf? 

I will investigate this.

Micha.






More information about the Lazarus mailing list