Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have a requirement in VC++6.0 where draw lines at desktop window between windows and erase them when is not needed. The lines are drawn from one window to another window passing through the desktop window. As part of the requirement the lines must be shown with different colors. I can use SetROP2 with R2_XORPEN which works perfectly for drawing and erasing lines using desktop widnow. But the line is on desktop is inverted with the combination of line color and desktop window color. I tried using Binary raster operations for suppressing this issue but none of the combination is resolved the issue. Could you help what is the solution for this?

regards
shanpalaniram
Posted

If you want your line to be drawn in plain color, then you shouldn't use SetROP2 with R2_XORPEN. Just use the normal mode to draw your line.

To "erase" the line, just invalidate the corresponding area with one of the Invalidate functions. For example:

C++
HWND hDesktopWnd = GetDesktopWindow();
//redraw the rectangle area which contains the line
InvalidateRect(hDesktopWnd, &rect, TRUE);
//or with a region
InvalidateRgn(hDesktopWnd, rgn, TRUE);
 
Share this answer
 
v2
Comments
mbue 16-Mar-11 13:27pm    
Thats right.
@OP: its not fine to paint over other windows. Create a single window for each line, that would be the better solution.
Regards
Sergey Alexandrovich Kryukov 16-Mar-11 21:49pm    
This is very bad, too. All rendering should be in one windows, all elements are light-weighted (not windows).
--SA
mbue 17-Mar-11 6:27am    
Your fail, you should to understand the intention of the op. hint: who's the owner of the desktop window?
Sergey Alexandrovich Kryukov 17-Mar-11 13:07pm    
Absolutely does not matter who is the owner, even if nobody.
Can you explain the difference? I can draw in desktop, what's the problem?
--SA
Sergey Alexandrovich Kryukov 16-Mar-11 21:50pm    
This is correct explanation, my 5, but the project leads nowhere. I saw many attempts to follow this line of "design". Nothing but epic fail each time.
--SA
I have never done what I will describe and therefore I can't tell wether it will work ot not, but you can try to host all your windows in a main window and make this main window transparent.

You would then draw the lines inside your main window as non-transparent, and can invalidate the main window easily.

Check this link to know how to make transparent windows:
http://msdn.microsoft.com/en-us/library/ms997507.aspx[^]

I hope this will help.
 
Share this answer
 
Comments
Shanmugam R P 21-Mar-11 13:02pm    
Thanks. This will not work for the requirement as I need to draw lines between window dialogs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900