Sonny gave 12 + 9 + 7 = <<12+9+7=28>>28 boxes of cookies.
Therefore, he was left with 45 - 28 = <<45-28=17>>17 boxes of cookies.
#### 17