Connect one length of wire from the terminal on a buzzer or alarm to the corresponding wire on a 9v battery holder. Do not place the battery in the holder yet.
Connect a second length of wire from the remaining terminal on the buzzer to the matching terminal on a reed contact NO (normally open) magnetic switch.
Connect the free wire on the battery holder to the remaining terminal on the magnetic switch.
Mount the terminal part of the switch to the inside from of the door or window you'd like to protect. Make sure it is placed flush with the frame so it won't interfere with opening and closing the door.
Mount the buzzer and battery pack on a nearby wall.
Mount the magnet half of the switch to the door or the window, parallel to the terminal half. The two halves should be in contact when the door or window is closed.
Connect a 9v battery to the holder, close the door or window, and turn the buzzer on. When the door or window is open, contact is broken between the magnet and the reed switch, and the buzzer should go off.