由shape控件得到rgn(2000/11/21 三金 版权所有
如有问题,请参考vcl库shape组件源代码
function getshapergn(shape:tshape):hrgn;
var
x, y, w, h, s: integer;
ret:hrgn;
begin
result:=0;
x :=shape.left+shape.pen.width div 2;
y :=shape.top+shape.pen.width div 2 ;
w :=shape.width- shape.pen.width + 1;
h :=shape.height-shape.pen.width + 1;
if shape.pen.width = 0 then
begin
dec(w);
dec(h);
end;
if w < h then s := w else s := h;
if shape.shape in [stsquare, stroundsquare, stcircle] then
begin
inc(x, (w - s) div 2); //得到新的x值
inc(y, (h - s) div 2); //得到新的y值
w := s;
h := s;
end;
case shape.shape of
strectangle, stsquare:
begin
ret:=createrectrgn(x, y, x + w, y + h);
if ret=null then
result:=0
else
result:=ret;
end;
stroundrect, stroundsquare:
begin
ret:=createroundrectrgn(x, y, x + w, y + h, s div 4, s div 4);
if ret=null then
result:=0
else
result:=ret;
end;
stcircle, stellipse:
begin
ret:=createellipticrgn(x, y, x + w, y + h);
if ret=null then
result:=0
else
result:=ret;
end;
end;
end;
更好更多文章尽在三金主页-天铭心草堂 http://vip.6to23.com/tianmingxin