I was wondering if anyone here knew how to forcefully constrict a window to a certain aspect ratio. For example, if a user tries to horizontally scale a window, the vertical would compensate and resize (in real time) so that the aspect ratio is unchanged. I know some games do this when in windowed mode, for example World of Warcraft.
I did a bit of research and Here are my findings (maybe you guys can offer other suggestions). First, is a hook to my own window. It would intercept the WM_SIZE event and modify the RECT that governs the window size. It would then uniformly adjust the size. This method is a bit ugly! Secondly, is to use the WM_NCHITTEST message. I would then capture the mouse movements and manually send them back into the Message queue so that WM_SIZE would be handled later on. Its cleaner then the previous way but still a bit nutty.