我使用Win API调用(多边形)在Delphi中绘制带有可选孔的填充区域。通过剪切区域切割的孔(不用bg颜色填充它们)。它工作正常,直到我调用打印预览(并且打印预览看起来很好,直到预览的页面不包含带孔的填充区域)。打印预览中的页面内容由填充区域的相同方法调用绘制,就在调用纸张大小缩放和裁剪区域设置在dc上之前。填充区域对象绘制方法不会通过页面剪切方法组合其自己的剪切操作。如何在页面切割夹和其他切割夹之间进行AND操作(切孔的应该是OR相互关联的)。
FilledArea对象绘制方法(仅剪裁特定行):
...
try
if ( fHoles^.getCount > 0 ) then
begin
// Get a copy of the page clipping rgn
getClipRgn( dc, rgnPrev );
for i := 0 to fHoles^.getCount-1 do
begin
...
// create a rgn to the Xth hole
rgn := createPolygonRgn( rgnPts^, rgnPtsCount, ALTERNATE );
if ( rgn <> 0 ) then
begin
// combine the Xth rgn with the active rgn (OR because there could be many holes in a single filled area)
extSelectClipRgn( dc, rgn, RGN_DIFF );
// releases the Xth rgn
deleteObject( rgn );
end;
...
end;
end;
// draw the polygon
finally
if ( fHoles^.getCount > 0 ) then
begin
// selects a copy of the page cutting rgn copy
selectClipRgn( dc, rgnPrev );
// releases the copy of the page cutting rgn
deleteObject( rgnPrev );
end;
end;
打印预览剪裁区域绘图代码:
// Creates a page clipping rgn
rcRegion := createRectRgn( rcDevLeft_, rcDevTop_, rcDevRight_ + 2, rcDevBottom_ + 2 );
try
// Selects a copy of the page clipping rgn
selectClipRgn( dc_, rcRegion );
...
// draw the page contents
...
finally
// Selects an empty clipping rgn
selectClipRgn( dc_, 0 );
// Releases the created page clipping rgn
deleteObject( rcRegion );
end;
答案 0 :(得分:0)
行。我找到了。我应该使用combineRgn Win API调用来定义两个传入区域之间的Boole操作。