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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

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.

hdcLB = (HDC) wParam;   // handle to list box display context
hwndLB = (HWND) lParam; // handle to list box
Value of wParam. Handle to the device context for the list box.
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>)

             //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 ?
seredaAuthor Commented:
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.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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.)
seredaAuthor Commented:
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?
>> Subclassing child was not available because
>> scrollbar is not in the client area.
That has nothing to do with it.  You can still sub-class the window.  The point to sub-classing the window was to "learn" when the sub-classed with was doing its drawing so that it can notify the parent after it is done drawing.  In this case it would have tobe after a WM_NCPANT instead of a WM_PAINT, that's all.

>> how parent can draw smth. over child window
>> without subclassing and other windows?
that's no big deal.  The parent can just get a DC for its client window and draw, it will draw over the child window (Unless the clip siblings style is specfied, but that can be gotten around easily.)  The hard thing is to not let the child window draw back on top of what the parent drew.  That is why the child had to be sub-classed, so the parent can learn when the child has drawn and "correct" what the child has drawn.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
seredaAuthor Commented:
Okay, thanks nietod.
Though not an exact answer or recommendation, it was useful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.