I would like to draw a frame around a combined region. Though FrameRgn
results true, the region is shown, but the frame isn't! Does anyone know
what's wrong here?
HR:=CreateRoundRectRgn(0+zx1,0,BalloonFormWidth+zx1,BalloonHeight,ra,ra);//create
region HR, works fine
HR1:=CreatePolygonRgn(n,3,ALTERNATE);//create region HR1, works fine
CombineRgn(HR,HR1,HR,RGN_OR);//combine regions HR or HR1 and assign it
to HR, works fine
SetWindowRgn(BalloonForm.Handle,HR,true);//assign combined region to
form, works fine
HBR:=CreateSolidBrush(RGB(0,0,255));//create blue brush
FrameRgn(GetDC(BalloonForm.Handle),HR,HBR,2,2);//draw frame, results
true but doesn't do anything
DeleteObject(HBR);dispose of brush
Thanks for advises, Mirko
-Dave
Resource leak alert! Never ever use GetDC this way! You have to return the
DC to the system using ReleaseDC.
Try to frame the region in the forms OnPaint event handler:
procedure TForm1.FormPaint(Sender: TObject);
var
temprgn: HRGN;
begin
// frame the window region
With Canvas.Brush Do Begin
Color := clBlack;
Style := bsSolid;
End;
temprgn := CreateRectRgn(0,0,1,1);
GetWindowRgn( Handle, temprgn );
FrameRgn( Canvas.Handle, temprgn,
Canvas.Brush.handle, 1, 1 );
DeleteObject( temprgn );
end;
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
"Peter Below (TeamB)" wrote:
> procedure TForm1.FormPaint(Sender: TObject);
> var
> temprgn: HRGN;
> begin
> // frame the window region
> With Canvas.Brush Do Begin
> Color := clBlack;
> Style := bsSolid;
> End;
> temprgn := CreateRectRgn(0,0,1,1);
> GetWindowRgn( Handle, temprgn );
> FrameRgn( Canvas.Handle, temprgn,
> Canvas.Brush.handle, 1, 1 );
> DeleteObject( temprgn );
> end;
This works fine, thank you for your advise.
But why does FrameRgn return true with a faulty DC?
Mirko