The two most important properties
of a bevel are its shape and its style. The Shape property is a TBevelShape
enumerator that controls how the bevel appears. You can set the bevel to appear
as a line, to show borders or to be empty. To set the shape of the bevel, click
it on the form to select it. On the Object Inspector, click Shape to
reveal its combo box and select from the list. To set the bevel’s shape
programmatically, use code such as this:
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Bevel1->Shape = bsFrame;
}
//---------------------------------------------------------------------------
|
The Style property is a TBevelStyle
enumerator that specifies whether the bevel will be lowered or raised with
regard to the surface of its host container.
The Bevel control has no other methods than the constructor
and the destructor. All of its methods are derived from its parent and ancestor
classes.
If you want to dynamically create a bevel, declare a TBevel
object. Using the new operator, assign it the bevel constructor
specifying the control component as the form on which the bevel will be
positioned. You must also specify the control parent of the bevel. You can
dynamically create a bevel inside of a function or another control’s event. In
the following example, a bevel is created in an OnClick event of a
button:
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TBevel* Bvl = new TBevel(Form1);
Bvl->Parent = this;
}
//---------------------------------------------------------------------------
|
If you create a bevel in a function, the control would not
be available to other sections of a program. If you want the control to be
global, declare a TBevel object in the unit’s header file in the
private or the public sections:
private: // User declarations
TBevel *Beauty;
In the form’s constructor, initialize the control using
the new operator and specifying the component that would host the control:
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Beauty = new TBevel(Form1);
}
//---------------------------------------------------------------------------
|
After creating the control, you can programmatically set its
properties. If the control was created locally, set these properties in the
function or event:
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TBevel* Bvl = new TBevel(Form1);
Bvl->Parent = this;
Bvl->Height = 115;
Bvl->Left = 8;
Bvl->Shape = bsFrame;
Bvl->Style = bsRaised;
Bvl->Top = 8;
Bvl->Width = 210;
}
//---------------------------------------------------------------------------
|
If you had created the control in the header file, you can
use a function or event to initialize the control:
//---------------------------------------------------------------------------
void __fastcall TForm1::ControlTheBevel()
{
Beauty->Parent = Form1;
Beauty->Left = 240;
Beauty->Width = 146;
Beauty->Top = 80;
Beauty->Height = 100;
Beauty->Style = bsRaised;
}
//---------------------------------------------------------------------------
|
To manipulate the control, you can use any event of the
form. For example, the following code sets the bevel’s anchors:
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
Beauty->Anchors = TAnchors() << akRight << akBottom;
}
//---------------------------------------------------------------------------
|
|