cppguy
cppguy

Reputation: 3713

How do I make a window that automatically resizes with its parent

I'm trying to create a child window that always fills its parent client area and is always the same size and position. My temptation is to call GetWindowLongPtr on the parent, hook its window proc and intercept the WM_SIZE and WM_MOVE messages and resize/move my child in response to those messages.

However the project I'm working on is written in WTL and I'm tempted to believe there's a WTL solution that is more graceful/savvy than this brute force interception of messages. I'm not very familiar with WTL and the documentation is sparse at best. I'm considering using CHAIN_MSG_MAP_MEMBER but I'm unsure how to determine when my handler for WM_SIZE would be handling the parent's message or the child's own WM_SIZE messages

I'd like the change to the parent class to be as nonintrusive as possible... perhaps a single line in the parent's message map. Also the parent can be any window, not just top level windows.

Upvotes: 3

Views: 1586

Answers (1)

UltimaWeapon
UltimaWeapon

Reputation: 2660

Use CDialogResize class. It is declared in atlframe.h. You can find some examples in the internet. This in the one of example.

Upvotes: 2

Related Questions