I have a function which processes messages and there I catch certain messages outside WindowProcedure to trigger wanted behavior.
The problem is that while it seems like other messages are working as needed, I can't catch the WM_SIZE message for some reason.
WM_SIZE is seen in the WindowProcedure, but I can't find a reason why it is not seen by my function.
Is the problem on my method of reading the current HWND?
The function currently is:
// OS MESSAGES
int OSMessages(void)
{
  MSG msg;
  HWND actwnd = GetActiveWindow();
  if ( PeekMessage(&msg, actwnd, 0, 0, PM_REMOVE) )
  {
    if (msg.message == WM_QUIT)
    {
      printf("QUIT");
      return -1;
    }
    else if (msg.message == WM_SIZE)
    {
      printf("RESIZE");
      return 1;
    }
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return 0;
}
                A message loop can only ever see messages that are posted to the calling thread's message queue.  WM_SIZE, however, is not a posted message, it is a sent message.  A sent message is delivered directly to a window's message procedure without going through the message queue at all (although a message loop has some influence on when a sent message is delivered to the message procedure).
That is why your message loop is not seeing WM_SIZE.  If you need it, you will have to subclass the target window itself using SetWindowsLong/Ptr() or SetWindowsSubclass() to hook in your own window procedure.
See MSDN for more details:
Messages and Message Queues
Subclassing Controls
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