|
|
What's the reason to have a "Clipping Region" in drawing a control? |
|
Author |
Message |
gsxrk5

|
Posted: Sun Feb 22 20:57:17 CST 2004 |
Top |
MFC >> What's the reason to have a "Clipping Region" in drawing a control?
Hello...
I'm programming a CListCtrl-derived control that is ownerdrawn fixed.
Currently it is working as I want, but by looking at other examples over the
internet, some programmers placed in DrawItem virtual function a code to set
a clipping region. I cut and pasted that code into mine, and the control
stopped displaying correctly.
This is the code I copied:
rcCol.right = rcCol.left + m_pParent->GetColumnWidth(m_nCol);
CRgn rgn;
rgn.CreateRectRgnIndirect(&rcCol);
cDC.SelectClipRgn(&rgn);
rgn.DeleteObject();
After the first instruction, rcCol contains the bounding rectangle of a
subitem (considering subitem = 0 to be the first column). What is wrong for
that code? if my control works as it is, will it be necessary to use a
clipping region? or the most important question, what is a clipping region
and which is its importance?
Thanks
Jaime
Visual Studio32
|
|
|
|
 |
Jase

|
Posted: Sun Feb 22 20:57:17 CST 2004 |
Top |
MFC >> What's the reason to have a "Clipping Region" in drawing a control?
> Hello...
>
> I'm programming a CListCtrl-derived control that is ownerdrawn fixed.
> Currently it is working as I want, but by looking at other examples over
the
> internet, some programmers placed in DrawItem virtual function a code to
set
> a clipping region. I cut and pasted that code into mine, and the control
> stopped displaying correctly.
>
> This is the code I copied:
>
> rcCol.right = rcCol.left + m_pParent->GetColumnWidth(m_nCol);
> CRgn rgn;
> rgn.CreateRectRgnIndirect(&rcCol);
> cDC.SelectClipRgn(&rgn);
> rgn.DeleteObject();
>
> After the first instruction, rcCol contains the bounding rectangle of a
> subitem (considering subitem = 0 to be the first column). What is wrong
for
> that code? if my control works as it is, will it be necessary to use a
> clipping region? or the most important question, what is a clipping region
> and which is its importance?
>
> Thanks
> Jaime
>
>
It's just for safety really. It makes sure that you don't draw outside the
area designated for that item or subitem.
Jase
|
|
|
|
 |
|
|