Re: Clip Region problem

"todd" <timza1221-/[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>

HI Thanks for the help!
Fixing a leak, and with a bit more work, I got it to work fine.  In case anyone has struggles with this type of thing, here are my 2 functions.  I am writing some custom clipping / exclusion code that works on a temporary basis.  My class contains a vector of rectangles with methods for 'GetFirst()', 'IsFirst()', 'IsNext()' meaning they exist, and 'GetNext() Here it is:
	
// ==============================
void Exclude(CDC odc)
	{
		odc.GetClipRgn(m_PrevRgn);
		EnterCriticalSection(&m_csClipMgr);
		CRect r;
		if (IsFirst())
		{
			r = GetFirst();
			odc.ExcludeClipRect(r);
			while (1)
			{
				if (!IsNext())
					break;
				r = GetNext();
				odc.ExcludeClipRect(r);
			}
		}

		odc.Detach();
		LeaveCriticalSection(&m_csClipMgr);
	}
void Allow(CDC odc)
	{
		odc.SelectClipRgn(m_PrevRgn,RGN_COPY);			
		odc.Detach();
	}
// ==============================






--- In [email protected], "domehead100" <domehead100@...> wrote:
>
> Some thoughts/questions...
> 
> 1)  Could you define "it's not working"?
> 
> 2)  Where does the HDC passed into the function come from?  If it's from GetDC, the clipping region is the entire window unless you change it.  If it's from BeginPaint or GetDCEx, then the clip region is the actual update region for the window.  That's a big difference.  
> 
> 3)  What about, this, instead of managing the regions directly:
> void drawing(CDCHandle dc)
> {
> int idc = dc.SaveDC();
> ... //code
> dc.RestoreDC(idc);
> }
> 
> 4)  Can you give a brief idea of what you're trying to accomplish?  Specifically, is this a ground-up custom window where you are doing all of the drawing, or it it a subclass of a base control?  There's a big difference here as well as to best ways to accomplish certain things.
> 
> 5)  With a quick bit of Googling, I came across this article, which you might find helpful:
> 
> http://www.codeproject.com/KB/GDI/cliprgnguide.aspx
> 
> Anyway, best of luck with this.
> 
> ~Mike
> 
> --- In [email protected], "todd" <timza1221@> wrote:
> >
> > I"m trying to restore the previous clip region after modifying it to draw.  What I'm doing is crashing for some unknown reason.
> > Any suggestions or improvements? 
> > THANKS!
> > Todd.
> > 
> > 
> > void drawing(CDC odc) // parameter set by caller hdc in window
> > {
> >   CRect r(1,1,10,10);    // Example rectangle to remove from drawing
> >   
> >   CRgn m_PrevRgn;       // PROBLEM? trying to restore previous RGN
> >   odc.GetClipRgn(m_PrevRgn);   // Read it, then restore it.
> > 
> >   odc.ExcludeClipRect(r);
> > 
> >   //... drawing code
> >   //... 
> > 
> >   odc.SelectClipRgn(m_PrevRgn,RGN_COPY);  // RESTORE
> > 
> >   odc.Detach();   // caller's DC
> > }
> >
>



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.