How to hook WIN32 WM_SYSCOMMAND and SC_SIZE and still enable window resizing? [duplicate]

StackOverflow https://stackoverflow.com/questions/23396080

  •  13-07-2023
  •  | 
  •  

Question

I'm intercepting (hooking) WMSYSCOMMAND and SC_SIZE messages for my application with intention of resizing child controls as user resizes the main window.

I'm successful at my primary goal, but a side effect occurred: main window is now not resized and user can not drag its borders to do so.

How do I react upon SC_SIZe to resize child controls and not block main window resize (I wan't it to work).

Thanks.

Was it helpful?

Solution

Resize your child controls in WM_SIZE and leave those other messages alone (letting them go to DefWindowProc).

There's a user-setting that controls whether windows are updated as they're sized. If you try to do what you're doing, you'll be overriding that setting, which is a rude thing to do to your users.

If the setting is enabled (which it is by default on modern version of Windows), your top-level window will receive WM_SIZE messages and WM_PAINT during the resize operation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top