I have custom Panel-component on my hands, I've done some enhancements to it (after inherited it), now I would need to have kind of functionality to detect when the mouse enters and leaves certain area of the component. I would like to change mouse cursor while user covers on the Caption I've drawn, if component is at certain state.

I have custom Panel-component on my hands, I've done some enhancements to it (after inherited it), now I would need to have kind of functionality to detect when the mouse enters and leaves certain area of the component. I would like to change mouse cursor while user covers on the Caption I've drawn, if component is at certain state.

Any ideas in what component to look for help, I tried to look on the VCL but did not happen to find any easy way to get mouse movements on the Component. Any pointers where to look from VCL, JVCL or some other publicly available source. have not done too much Custom component development, so any help is going to make my (second) day on this ;)

Comments

  1. If you want to detect when the mouse enters/leaves your control area, define two methods in your control:

    procedure CMMouseEnter(var msg: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var msg: TMessage); message CM_MOUSELEAVE;

    ReplyDelete
  2. This probably helps with mouse move:
    http://stackoverflow.com/a/21307387

    For enter and leave you could also overwrite TControl.DoMouseEnter and DoMouseLeave. Within these call inherited if you want the event to propagate to the panel's parent controls.

    ReplyDelete

Post a Comment