Is it possible to somehow cleverly use PostMessage, GetMessage, etc. to queue LIFO messages (assuming both the sender and the receiving message loop cooperate), or would I need to roll my own solution?
In case you’re wondering about the use case, it’s icon loading. You always want to load the most recently requested icons first. 🙂
No, you need to roll your own – the windows message queue has a maximum size, and if it ever gets full all sorts of things go badly wrong, from COM, DDE to user interaction.
Instead of using the thread queue, you should use a deque (or similar) protected by a critical section.
See also an example of what can go wrong: