且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检测没有焦点的控件中的修改键更改?

更新时间:2022-02-06 09:49:07

我会写一个 WM_SETCURSOR 消息以调用 GetKeyboardState 来获取键盘状态(在Delphi中,您只需调用KeyboardStateToShiftState ),并根据该结果(以及点击测试)调用 SetCursor ,并带有适当的光标。

I would write a message handler for WM_SETCURSOR message to call GetKeyboardState to get the keyboard state (in Delphi you can just call KeyboardStateToShiftState) and based on the result of that (and the hit test) call SetCursor with the appropriate cursor.

要处理 WM_SETCURSOR ,在VCL中有一个示例: TCustomGrid.WMSetCursor 网格单元。

For handling WM_SETCURSOR, there's an example in the VCL: TCustomGrid.WMSetCursor in the Grids unit.