Hi I have a form with several frames inside.
For some frames, I want to scroll through the contents (or at least handle the mousewheel event).
I tried the following:
Just assign an OnMouseWheel event handler to each frame
Overriding the MouseWheel event for the parent form:
procedure TFmReview.MouseWheelHandler(var Message: TMessage); var Control: TControl; begin Control := ControlAtPos(ScreenToClient(SmallPointToPoint(TWMMouseWheel(Message).Pos)), False, True); if Assigned(Control) and (Control <> ActiveControl) then begin ShowMessage(Control.Name); Message.Result := Control.Perform(CM_MOUSEWHEEL, Message.WParam, Message.LParam); if Message.Result = 0 then Control.DefaultHandler(Message); end else inherited MouseWheelHandler(Message); end;
Unfortunately, both do not work.
- In case 1, the event never fires, but the parent forms the mouse wheel handler.
- In case 2, the control that receives the focus is the panel in which the frame to which I want to send the mouse event is located.
So just tell me, how can I direct the mousewheel event to the topmost control that the mouse cursor has ended over (regardless of which frame / parent / form, etc. the cursor is on)?
source share