Link to home
Start Free TrialLog in
Avatar of sereda
sereda

asked on

drawing over child window

Parent window has to draw over the child window (listview). For example, to change the look of a scrollbar. Since WM_PAINT goes to the parent window first and to the child second, and the child window procedure is not available, i can't think of a solution.
So the question - how can i do it?
Thanks.
Avatar of nietod
nietod

Why not just hide the child window?

Other than that, I think you will have to sub-class the child window, so that it can notify the parent window after it has drawn so the parent window can draw on top of it.
I really dont understand what you are talking about when you say "draw over the child window .... to change the look of a scrollbar" - a little more info might be useful.

However - look at

WM_CTLCOLORLISTBOX
The WM_CTLCOLORLISTBOX message is sent to the parent window of a list box before the system draws the list box. By responding to this message, the parent window can set the text and background colors of the list box by using the given display device context handle.

WM_CTLCOLORLISTBOX
hdcLB = (HDC) wParam;   // handle to list box display context
hwndLB = (HWND) lParam; // handle to list box
 
Parameters
hdcLB
Value of wParam. Handle to the device context for the list box.
hwndLB
Value of lParam. Handle to the list box.
Return Values
If an application processes this message, it must return a handle to a brush. The system uses the brush to paint the background of the list box.

Default Action
The DefWindowProc function selects the default system colors for the list box.

ie - this changes the background of the listbox to GREEN (a nice fluroescent green <s>)

    case WM_CTLCOLORLISTBOX :
            {
             //HDC hdcEdit = (HDC) wParam;   // handle of display context
             //HWND hwndEdit = (HWND) lParam; // handle of static control
         // Set text to white and background to green

         SetTextColor((HDC) wParam, RGB(255, 255, 255));
         SetBkColor((HDC) wParam, RGB(0, 255, 0));

         return (LRESULT) hbrGreen;

            }


Where hbrGreen is declared as
static HBRUSH hbrGreen;

Is this the info you were looking for ?
Avatar of sereda

ASKER

Sorry but i have list view, not list box. And it seems to be very self-confident about what should be drawn on it :(

Subclassing is a good idea, but the question is how to make it without subclassing - for some reasons subclassing is not available.
Can you explain why?  Can you give us more details of the situation?  You need some way of knowing when the child has painted. (and that is sort of too late, as you will see a "flash" if you let the child paint, and then you paint on top of it.)
Avatar of sereda

ASKER

Subclassing child was not available because scrollbar is not in the client area. To make matter worse, the whole window is ATL control.

Flash may be avoided if we can clip out some area from child repaint region.

Anyway, we resolved to do this another way - to paint another (static) child window over listview with transmitting mouse clicks behind.

But i will gladly give points to anyone who provides the answer to initial question - how parent can draw smth. over child window without subclassing and other windows?
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sereda

ASKER

Okay, thanks nietod.
Though not an exact answer or recommendation, it was useful.