Here is you code:
Code:
PANEL* test_pan =
{
	bmap = "cool.bmp";
	layer = 5;
	flags = SHOW;
}

function drag()
{
	var diff_x, diff_y;
	while(1)
	{
		if((mouse_left)&&(mouse_pos.x >= test_pan.pos_x)&&(mouse_pos.x <= test_pan.pos_x+bmap_width(test_pan.bmap))&&(mouse_pos.y >= test_pan.pos_y)&&(mouse_pos.y <= test_pan.pos_x+bmap_height(test_pan.bmap)))
		{
			diff_x = mouse_pos.x - test_pan.pos_x;
			diff_y = mouse_pos.y - test_pan.pos_y;
			while(mouse_left)
			{
				test_pan.pos_x = mouse_pos.x - diff_x;
				test_pan.pos_y = mouse_pos.y - diff_y;
				wait(1);
			}
		}
		wait(1);
	}
}



And this in the main:
Code:
....
drag();
	while(1)
	{
		mouse_pos.x = mouse_cursor.x;
		mouse_pos.y = mouse_cursor.y;
		wait(1);
	}