3

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.

cppguy
  • 3,611
  • 2
  • 21
  • 36
  • 3
    Usually the parent will respond to its own `WM_SIZE` message and resize the child. – user1793036 May 23 '14 at 01:54
  • In this case I'm trying to make a generic control that can be placed over any other window's children ostensibly blocking input to them and rendering a message over top. – cppguy May 23 '14 at 16:19
  • @cppguy: Putting a child window above (in z-order sense) other child windows will not block keyboard input to the underlying windows, only mouse clicks. You would have to make sure that the other children are disabled and that the message loop doesn't forward any special messages to the children (e.g., via accelerators). And what if the parent creates a new control after your covering window is active? – Adrian McCarthy Aug 23 '14 at 22:15

1 Answers1

2

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

UltimaWeapon
  • 2,343
  • 18
  • 19
  • CDialogResize requires me modifying the parent class inheritance which I'd rather not do. I'll update my question – cppguy May 23 '14 at 16:24