0
votes

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.

2
Without the code example one can only guess. May be your Text Editor component receives wrong WM_SETFOCUS message after it received WM_KILLFOCUS and actully lost focus.kludg
Unfortunately, that wasn't it...Andreas Rejbrand

2 Answers

1
votes

I found a trivial bug in the component's code. My apologies.

0
votes

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.