Win32 and catching WM_SIZE message outside WindowProcedure

I have a function that processes messages, and there I catch certain messages outside of WindowProcedure to trigger the desired behavior.

The problem is that although it seems that other messages work as needed, for some reason I cannot catch the message WM_SIZE. WM_SIZEdisplayed in WindowProcedure, but I can not find the reason why my function is not visible. Is there a problem in my method of reading the current HWND?

Currently function:

// 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;
}
+4
source share
2 answers

, . WM_SIZE, , , . , ( , ).

WM_SIZE. , SetWindowsLong/Ptr() SetWindowsSubclass(), .

. MSDN:

+9

WM_SIZE . . , , , , .

, .

+3

Source: https://habr.com/ru/post/1653747/


All Articles