• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

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.
0
sereda
Asked:
sereda
  • 3
  • 3
1 Solution
 
nietodCommented:
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.
0
 
DarrinECommented:
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 ?
0
 
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.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
nietodCommented:
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.)
0
 
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?
0
 
nietodCommented:
>> 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.
0
 
seredaAuthor Commented:
Okay, thanks nietod.
Though not an exact answer or recommendation, it was useful.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now