Thank you very much for your reply and your example project. I appreciate your help very much.
Because of your example I can explain my problem better. Your example works fine and does indeed what I expect it to do, as long as you keep your mousepointer in the white and black erea.
However when your mousepointer comes over the taskbar or over the toolbar on top, movement of the orange square stops. That is exactly what I do not want it to do. At least the orange square should move left or right following the horizontal movement of the mousepointer.
Imagine having a runtime (.exe) where the orange square's movement is restricted to horizontal only (left/right) even when you move your mousepointer up or down, the square should always be on the same line horizontally.
The fence should act like a window, where the mousepointer cannnot get out.
I am coming from a programming background and maybe I am thinking wrongly or in the wrong direction. I have the impression that my kind of thinking is flawed. If that is so, please feel free to tell me.
Thank you again for your help, your example was very helpfull.