The solution to my problems was to add to the end my Xemacs configuration file (Users/my_user_name/.xemacs/init.el) following lines:
(define-key global-map 'button4
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 5)
(select-window curwin)
)))
(define-key global-map [(shift button4)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 1)
(select-window curwin)
)))
(define-key global-map [(control button4)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down)
(select-window curwin)
)))
(define-key global-map 'button5
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 5)
(select-window curwin)
)))
(define-key global-map [(shift button5)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 1)
(select-window curwin)
)))
(define-key global-map [(control button5)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up)
(select-window curwin)
)))
This is what I was looking for, and what's the most important - it worked.
In addition to that, I did exactly the same thing to my XEmacs on my Solaris server (I use X11 to work remotely on Solaris from my Mac). It worked also.