What do you mean by "lock when they're closed" - do you mean the standard window locks? Like it's either keep them closed completely or open completely?
Our windows have locks in the frames that prevent them from opening more than about 3 inches. If they have something like that, that has been plenty to keep DS inside. He can look out, he can stick his hand out to touch the screen, but that's it. The lock is above my head, so no way he can get it open on his own. If your windows don't have that type of lock, there are after-market locks that you screw onto the frame (not into - they don't damage the frame) that do the same thing - preventing the window from opening past a certain point. Not sure you'll find them in the childproofing department, I see them in the hardware store - just ask for window locks.
If your windows are crank or otherwise open out/in instead of up/down, then that's a different matter and requires a different solution. Not sure I'd trust a pressure mounted gate in a window though (like you shouldn't trust one at the top of the stairs), and you didn't specify whether you were renting/buying, so not sure whether you can install something permanent.
Follow Mothering