Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using FrameRgn

67 views
Skip to first unread message

Dr. Mirko Neumann

unread,
Sep 22, 2000, 3:00:00 AM9/22/00
to
Hallo,

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

David Novo

unread,
Sep 22, 2000, 3:00:00 AM9/22/00
to
Could it be that since your form is the size of the region there is nothing to frame?
Try doing it without making your windowrgn HR and just leave balloon form really big.
That way if there is something to draw you should see it.

-Dave

Peter Below (TeamB)

unread,
Sep 23, 2000, 3:00:00 AM9/23/00
to
In article <39CB3DB2...@t-online.de>, Dr. Mirko Neumann wrote:
> FrameRgn(GetDC(BalloonForm.Handle),HR,HBR,2,2);//draw frame, results
>

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!


Dr. Mirko Neumann

unread,
Sep 25, 2000, 3:00:00 AM9/25/00
to
Hallo Peter,

"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


0 new messages