Most of the time the frame will be fine and only the screen will need to be replaced. If the frame can't sit flush within the channels of the window it will need to be replaced. Unfortunately, fixing anything more than small dents or bends is hard to do at home.
When replacing a screen, the first thing to determine is if the frame itself is damaged. Fortunately, replacing a window screen is an easy and inexpensive process that anyone can do. In addition, the frame could be damaged if something hits the window or if a bad storm blows the screen off the window. They often get cut or punctured, and over time they will wear out and tear.