Code:
var gv;
function buttonpro(var i, PANEL* p)
{
   if (p == my_firstPanel)
   {
     //only if this specific panel is clicked
     if (i == 1)
     {
        //first button of the panel
     }
     if (i== 2)
     ....
   }
   if (p == my_secondPanel)
   {
   .....
   }
}
pan_setbutton(gp[0],0,1,0,0,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL); //btn1
pan_setbutton(gp[0],0,1,0,40,gb[1],gb[2],gb[3],NULL,buttonpro,NULL,NULL);//btn2



The function gets the number of the button and a pointer to the panel passed automatically.


I <3 LINQ