This could very well be another silly question, but I can’t seem to find the answer (or any for that matter), so here goes.
I have a command line program that uses SIGWINCH on Linux to detect the window size change, and I apparently have a user who is using the program on Windows. The problem, is that the program uses SIGWINCH to detect changes in the window size and this signal is unsupported on Windows. I’ve tried Googling for every combination of search terms I can think of, but due to the relationship between SIGWINCH and changes in the size of the window, I’m having trouble finding any useful results. I’m looking for a Windows equivalent, or the method most often used to detect changes in the window size on Windows computers.
How do you detect changes in window size on Windows?
Since I don’t think you can subclass console windows (and thus catch
WM_SIZEmessages), you may just have to pollGetConsoleScreenBufferInfo.EDIT: Upon further investigation (not tested!), it might also be doable without polling using
ReadConsoleInput. Summary: CallSetConsoleModeto turn on window input events. From a different thread, wait for the console input handle to become signaled usingWaitForSingleObjector a similar function. Read all pending console events; the presence of window buffer size events means something’s resized your console window.