Pad under mouse cursor and mouse wheel events

Hi all,
I’m tring to find a way to detect the pad wich happens to be under
mouse cursor. So far i found the following way to do that:

void DoZoom(Int_t evt, Int_t px, Int_t py, TObject *obj)
{
  if(evt!=5 && evt!=6) return; //5- zoom in 6-zoom out
  const Int_t minZoom=64;
  const Int_t maxZoom=2;
  static Int_t zoom=minZoom; //zoom level
  if(evt==5&&zoom==maxZoom) return; 
  if(evt==6&&zoom==minZoom) return; 
  
  if(!obj->IsA()->InheritsFrom("TPad")) return;  //current object is not pad
  TPad *pPad=(TPad*)obj;
  if(pPad->GetNumber()==3 || pPad->GetNumber()==7) return; //current pad is wrong

This code does not provide the pad in case the cursor is close to some
primitives like TMarker, hence this event is ignored.
So the question is how to check what is the pad under mouse pointer (not the
current pad gPad, which might be different)?

Second question: mouse wheel events (number 5 and 6) are only avail in
the function connected by canvas->Connect(“ProcessedEvent()…”).
They are not available in function connected by AddExec. (root v5.14.00 on linux 32bits). Why?

you can use:

TVirtualPad *pad = gROOT->GetSelectedPad();
Rene

No, GetSelectedPad returns the pointer to the pad which was selected
by gPad->cd() or middle click. I wanna get the pointer to the pad which
contains a mouse cursor.

Sorry, use gPad->GetSelectedPad

Rene