Board index » cppbuilder » Creating an irregular shaped form in DESIGN time

Creating an irregular shaped form in DESIGN time

Hi
My problem is descriped in the subject topic above. I know how to change
the shape during runtime using SetWindowRgn but not during design time.
Does Windows allocate any handles to any of the components during design
time???

Secondly I would like to know how to change the ClientRegion of a
control during both design time and runtime. The help files says that
one can set it by changing ClientRect but this is a read-only property!!

Any ideas
Thanks
Tim

 

Re:Creating an irregular shaped form in DESIGN time


Hi Tim,

Quote

> Hi
> My problem is descriped in the subject topic above. I know how to change
> the shape during runtime using SetWindowRgn but not during design time.
> Does Windows allocate any handles to any of the components during design
> time???

Yes, all you have to do is find the owner Form, then create and set the region.
Be sure to delete the region when you're done.

//in header...
    HRGN HFormRgn;

__fastcall TMyControl::TMyControl(TComponent* Owner)
    : TCustomControl(Owner)
{
    TForm *OwnerForm = dynamic_cast<TForm *>(Owner);
    if (OwnerForm)
    {
        HFormRgn = CreateEllipticRgn(0, 0, OwnerForm->Width,
                                     OwnerForm->Height);
        if (HFormRgn) SetWindowRgn(OwnerForm->Handle,
                                   HFormRgn, true);
    }

Quote
}

__fastcall TMyComponent::~TMyComponent()
{
    DeleteObject(HFormRgn);

Quote
}

You may also want to restore the original region if your component is deleted.

Good luck.

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

Re:Creating an irregular shaped form in DESIGN time


Thanks for the help Damon but regarding the ClientArea, how can one change the
offset and not just the ClientWidth and ClientHeight??? The help files says that
ClientRect is read-only.
Thanks
Tim

Re:Creating an irregular shaped form in DESIGN time


Hi!

You could be looking for the OffsetRgn function? Dunno...

Anyway, check out http://www.gcs.co.za/mbs/transformpack/
It allows you to preview your transparent forms at design-time....

Hope it helps...
Louis

Quote
Tim Chemaly wrote in message <37924BA5.F0087...@ing.sun.ac.za>...
>Hi
>My problem is descriped in the subject topic above. I know how to change
>the shape during runtime using SetWindowRgn but not during design time.
>Does Windows allocate any handles to any of the components during design
>time???

>Secondly I would like to know how to change the ClientRegion of a
>control during both design time and runtime. The help files says that
>one can set it by changing ClientRect but this is a read-only property!!

>Any ideas
>Thanks
>Tim

Other Threads