Mouse, scroll wheel, keyboard

I am trying to add wheel functionality to an old existing app in Free Pascal. Currently the mouse and kybd are supported by two different drivers.
The mouse has some assembly code in it but predates the wheel and therefore doesn’t support it. I tried to find a hardware description of the
wheel interface with no luck. I found the SDL Free Pascal tutorial which in chapter 8 describes mouse and kybd. I ran the demo code successfully.
The demo code opened a new window outside of the window from which the demo was launched. The mouse would only report coordinates
in the new window. The scroll wheel worked every where. Nothing worked unless that window was created. I want the mouse to work in the
app window and not in a new window. I tried to use only the wheel code along with my kybd and mouse code but they interfered.

Can I get the mouse to work in the launch window instead of a new window?

Thanks JY