Hey this is for anyone who is interested in this stuff..

Till now, i didnt know of a good way of updating a custom CHILD control of a parent window, when the parent is resized. The only way i knew of was to have the Parent send a WM_SIZE message down to the child. This was a headache, and the control was less encapsulated.

I just discovered a method of doing this..

    [*]Handle the WM_ERASEBKGND message..
    [*]When handling, call GetParent..
    [*]Then call GetClientRect or GetWindowRect, depending of how you want to suport sizing...
    [*]Do whatever you need to do with the info..
    [*]Call SetWindowPos on the control window when you have a new size figured out. Ensure you ADD SWP_NOREDRAW in the flags!!! Took me 3 Reboots to discover this need ;) ~ else you get into an endless feedback loop.
    [*] return 1, indicate its been handled.


    Sounds like a bit, but it really isnt.. Enjoy!
    :alright:
    NaN
Posted on 2002-06-02 22:27:58 by NaN
Another way could be to let the custom control subclass its parent window, handling WM_SIZE before its 'daddy'. This way the custom control will be much more incapsulated.
Posted on 2002-06-03 13:08:25 by LuHa
Ya.. good idea.. didnt think of that... bit more overhead.. but probably more precise.

My method above works well, but i found out that the tool-tips that popup over the 'close' 'maximize' 'restore' buttons, also generate a WM_ERASEBKGND message when they are removed.

This means, at least in my uses, it rebuilds back bufffer bitmaps, needlessly.

Thanx for the suggestion!
:alright:
NaN
Posted on 2002-06-03 14:35:03 by NaN
I didn't think abot the overhead, you are right, every parent window's message will transit via your control's message procedure.... There will never be the perfect solution for a problem :rolleyes:.
Posted on 2002-06-03 14:45:50 by LuHa