开发者

Delphi Focus Problem seen by Caret

开发者 https://www.devze.com 2022-12-21 06:05 出处:网络
I h开发者_JAVA技巧ave 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

I h开发者_JAVA技巧ave 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消