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_SIZE
messages), you may just have to poll GetConsoleScreenBufferInfo
.
EDIT: Upon further investigation (not tested!), it might also be doable without polling using ReadConsoleInput
. Summary: Call SetConsoleMode
to turn on window input events. From a different thread, wait for the console input handle to become signaled using WaitForSingleObject
or a similar function. Read all pending console events; the presence of window buffer size events means something's resized your console window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With