I have written an advanced text editor component (fixed-width, syntax highlighting, etc.) in Delphi, using Windows API combined with the TCanvas element, and it works great, except for one thing: If I set focus to another control inside the same application that displays a caret as well, such as a TEdit, stealing focus from my editor component, the caret of the new editor (such as TEdit) is not shown; instead the caret moves in my editor component! For example, if I write a character in the new editor (TEdit), it will show up as expected, and the caret will move to the right in my component. What can cause this? I suspect there is some conflict between Win API's handling of keyboard focus and the VCL handling. In my editor component, I use CreateCaret in response to WM_SETFOCUS and DestroyCaret in response to WM_KILLFOCUS. Apparently the problem only occurs if the new edit control is in a new, modal, window.
A:
My first thought would be that you're not getting the WM_KILLFOCUS message. I would construct a diagnostic to tell you whether it's happening or not.
I am NOT inclined to use a debugger for this sort of problem, I find doing things like modifying the title works better when trying to diagnose interactions like this.
Loren Pechtel
2010-02-27 22:23:41
Thanks, but I am positive that the code is executed. (I have tried with beep.)
Andreas Rejbrand
2010-02-27 23:28:17
A:
I found a trivial bug in the component's code. My apologies.
Andreas Rejbrand
2010-02-28 18:26:49
Then please accept an answer (Loren's or yours). That will remove the unanswered flag.
François
2010-02-28 19:09:22
I'll do that in four hours. (The server won't let me do it now.)
Andreas Rejbrand
2010-03-01 17:20:24