That's exactly how you write GUI applications on most systems!
This is how you do GUI events for Win32, X11 (Linux), OSX and even SDL.
Only difference it that for games you want Peek, not Wait for next message. If there is no message you want to update game state and render. For GUI applications that's not really needed. They can use low resolution timers (on Windows SetTimer function) that produces events/messages if you need some action to happen periodically.