User: alciro    User
 

Programación en C++ Builder

Share |
 Arrays (matrices)
 Punteros
3. Ejemplo de clase en c++
8. Métodos de la clase AnsiString
 Proyectos en C++
 Packages, distribuir una aplicación sin instalación
 Ordenación por intercambio o burbuja
 Funciones de cadenas de caracteres string.h

6.2. Derivadas de TscrollingWinControl

Estas propiedades controlan las barras de desplazamiento de un formulario. Si AutoScroll tiene el valor true (valor por defecto) las barras aparecen automáticamente cuando el formulario es demasiado pequeño para dar cabida a todos los componentes.


AutoScroll

Indica cuando las barras de desplazamiento aparecen automáticamente cuando los objetos no caben en el formulario.

__property bool AutoScroll = {read=FAutoScroll, write=SetAutoScroll, default=1};

 

HorzScrollBar
Representa la barra de desplazamiento horizontal.

__property TControlScrollBar* HorzScrollBar = {read=FHorzScrollBar, write=SetHorzScrollBar};

 

VertScrollBar
Representa la barra de desplazamiento vertical.

__property TControlScrollBar* VertScrollBar = {read=FVertScrollBar, write=SetVertScrollBar};

This example starts the form in a position scrolled so that the right hand edge shows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  /* set the width of the form window to display 300 pixels in the client area */

  ClientWidth = 300;

  /* now set the range to twice the client width.

   This means that the form has a logical size that is twice as big as the physical window.
   Note that Range must always be at least as big as ClientWidth! */

  HorzScrollBar->Range = 600;

  /* start the form fully scrolled */

  HorzScrollBar->Position = HorzScrollBar->Range - ClientWidth;

  /* clicking the scroll arrows moves the form 10 pixels */

  HorzScrollBar->Increment = 10;
  HorzScrollBar->Visible := true;  // Show the scrollbar
}

6.3. Derivadas de TWinControl

ClientOrigin
Indica las coordenadas de pantalla (en pixels) de la esquina izquierda, superior del área de cliente del control.

__property tagPOINT ClientOrigin = {read=GetClientOrigin};

Read ClientOrigin to discover where the top-left corner of the control is on the screen. ClientOrigin returns X and Y coordinates in a record of type tagPOINT. The tagPOINT type defines a pixel location onscreen, with the origin in the top left corner of the control. X specifies the horizontal coordinate of the point, Y specifies the vertical coordinate.


ControlCount

Indica el número de controles situados en un control contenedor.

__property int ControlCount = {read=GetControlCount, nodefault};

This example uses a group box on a form, with several radio button controls contained within the group box. The form also has an edit box and a button outside of the group box. The code sets the parent of the radio buttons to the radio group. It then counts each control's child controls turning each of them invisible as they are counted. The total number of controls counted appears in the edit box.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
	RadioButton1->Parent = RadioGroup1;
	RadioButton2->Parent = RadioGroup1;
	RadioButton3->Parent = RadioGroup1;

	for(int i=0; i < RadioGroup1->ControlCount; i++)
		RadioGroup1->Controls[i]->Visible = false;
	Edit1->Text = String(RadioGroup1->ControlCount) + String(" controls");
}

 

Controls
Es un array de todos los controles situados en un control contenedor.
Nota: Mirar el ejemplo de ControlCount.

__property TControl* Controls[int Index] = {read=GetControl};

 

Ctl3D
Determina cuando el control se puede ver en tres dimensiones (3-D) o dos dimensiones.

__property bool Ctl3D = {read=FCtl3D, write=SetCtl3D, stored=IsCtl3DStored, nodefault};

The following code toggles the 3-D look of a memo control when the user clicks a button named Toggle:

void __fastcall TForm1::ToggleClick(TObject *Sender)
{
Memo1->Ctl3D = !Memo1->Ctl3D; //Toggles the Ctl3d property of //Memo1
}

 

Handle

HelpContext
Establece el identificador de ayuda contextual de un formulario. Si se dispone de ayuda contextual, Windows la muestra cuando se pulsa F1. El indicador sirve para indicar al sistema de ayuda qué página del archivo de ayuda debe mostrar.

typedef int THelpContext;
__property Classes::THelpContext HelpContext = {read=FHelpContext, write=FHelpContext, default=0};

ParentWindow
Showing

TabOrder
Indica la posición del cursor en las ordenes de tabulación.

__property TTabOrder TabOrder = {read=GetTabOrder, write=SetTabOrder, default=-1};

This example ensures that the check box on the form is the first in the tab order, and therefore, the active control whenever the form appears, no matter how many other controls are on the form:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    CheckBox1->TabStop = true;
    CheckBox1->TabOrder = 0;
}

 

TabStop
Determina si el usuario puede acceder al control con la tecla de tabulación.

__property bool TabStop = {read=FTabStop, write=SetTabStop, default=0};

This code removes ListBox1 from the tab order, so that the user can't use the Tab key to get to the list box:

ListBox1->TabStop = false;

6.4. Derivadas de TControl

Align
Determina la alineación del control respecto a su contenedor.

enum TAlign { alNone, alTop, alBottom, alLeft, alRight, alClient };
__property TAlign Align = {read=FAlign, write=SetAlign, default=0};
Value Meaning
AlNone The component remains where it was placed on the form or panel. This is the default value.
AlTop The component moves to the top of the form and resizes to fill the width of the form. The height of the component is not affected.
AlBottom The component moves to the bottom of the form and resizes to fill the width of the form. The height of the component is not affected.
AlLeft The component moves to the left side of the form and resizes to fill the height of the form. The width of the component is not affected.
AlRight The component moves to the right side of the form and resizes to fill the height of the form. The width of the component is not affected.
AlClient The component resizes to fill the client area of a form. If a component already occupies part of the client area, the component resizes to fit within the remaining client area.
// dynamically create a TProgressBar control

// and align it to the bottom of the form.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TProgressBar *ProgressBar = new TProgressBar(this);
ProgressBar->Parent = this;
ProgressBar->Align = alBottom;
} 

 

BoundsRect

 

Caption
Especifica el texto que identifica el control para su uso.

__property System::AnsiString Caption = {read=GetText, write=SetText};

The following code keeps the size of the label control constant, even though the length of the label's caption changes. As a result, the caption of the label is probably too long to display in the label when the user clicks the button:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    Label1->AutoSize = false;
    Label1->Caption = "This string is too long as the caption of this label";
}

 

Color
Especifica el color de fondo del control.

__property Graphics::TColor Color = {read=FColor, write=SetColor, stored=IsColorStored, default=-2147483643 };

The following code changes the color of a shape control using the Color dialog box. The example displays the Color dialog box when the Button1 button is clicked, allowing the user to select a color with the dialog box. When a color value is selected with the dialog box, it is assigned to the shape control.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if (ColorDialog1->Execute)
    Shape1->Color = ColorDialog1->Color;
}

 

Cursor
Especifica la imagen usada para representar el puntero del cursor cuando este pasa por la región del control.

__property TCursor Cursor = {read=FCursor, write = SetCursor, default=0};

crDefault Whatever cursor is the default for the window class. Usually crArrow.

Imagen usada para representar el puntero del cursor.

Enabled
Propiedad que indica cuando el control responde a los eventos del ratón, teclado y timer.

__property bool Enabled = {read=FEnabled, write=SetEnabled, default=1};

To disable a button called FormatDiskButton,

FormatDiskButton->Enabled = false;

 

Font
Controla los atributos del texto del control.
Tipo de letra que se utiliza en el formulario. El tipo de letra especificada para el formulario es inherente a cualquier componente emplazado dentro de él (depende de la propiedad ParentFont).

__property Graphics::TFont* Font = {read=FFont, write=SetFont, stored=IsFontStored};

To change to a new font, specify a new TFont object. To modify a font, change the value of the Color, Height, Name, Pitch, Size, or Style of the TFont object.

To use this example, place a TComboBox and TRichEdit on a form.
During form creation, a list of font names are loaded into the combo box. When the combo box is clicked, the Rich Edit control font is set to the corrosponding font name in the combo box.

void __fastcall TForm1::FormCreate(TObject *Sender)
{
for (int i = 0; i < Screen->Fonts->Count; i++)
ComboBox1->Items->Add(Screen->Fonts->Strings[i]);
}

void __fastcall TForm1::ComboBox1Click(TObject *Sender)
{
RichEdit1->Font->Name = ComboBox1->Items->Strings[ComboBox1->ItemIndex];
}

 

Height
Especifica la altura del control o formulario en pixels.

__property int Height = {read=FHeight, write=SetHeight, nodefault};

 

Hint
Contiene el texto que aparece cuando se mueve el ratón sobre el control.

__property System::AnsiString Hint = {read=FHint, write=FHint};

Edit1->Hint = "Name|Enter Name in the edit box";

The "Name" string appears in the Help Hint box, and the "Enter full name in the edit box" string appears as specified in the OnHint event handler.

This example uses an edit box and a list box on a form. Items are added to the list box and a Help Hint is assigned to both controls. The last statement enables the Help Hints for the entire application.

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    Edit1->Hint = "Enter your name";
    Edit1->ShowHint = true;

    char string[10];
    char index[3];

    for(int i = 1; i <= 10; i++){
	itoa(i, string, 10);
	strcpy(string, "Item");
	itoa(i, index, 10);
	strcat(string, index);
	ListBox1->Items->Add(string);
    }
    Hint = "Select an item";
    ShowHint = true;
    Application->ShowHint = true;
}

 

Left
Especifica la distancia entre la parte izquierda del componente y el contenedor en pixels (coordenada X).

__property int Left = {read=FLeft, write=SetLeft, nodefault};

 

ParentFont
Determina cuando el control utiliza la fuente definida para su contenedor y no la suya.

__property bool ParentFont = {read=FParentFont, write=SetParentFont, default=1};

This example uses a timer component and a label control. When an OnTimer event occurs and the label uses its parent's font, the code changes the label's ParentFont property to False and changes the label's font size to 30 points. When an OnTimer event occurs and the label doesn't use its parent's font, the code sets its ParentFont to true. The result is that the label's font grows and shrinks alternately, each time an OnTimer event occurs.

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
    if(Label1->ParentFont == true)
	Label1->Font->Size = 30;
    else
	Label1->ParentFont = true;
}

 

PopupMenu

 

ShowHint
Determina si se visualiza o no el texto que aparece cuando se mueve el ratón sobre el control.
Mirar la propiedad Hint.

__property bool ShowHint = {read=FShowHint, write=SetShowHint, stored=IsShowHintStored, nodefault};

 

Top
Especifica la distancia entre la parte superior del componente y el contenedor en pixels (coordenada Y).

__property int Top = {read=FTop, write=SetTop, nodefault};

 

Width
Especifica la anchura del control o formulario en pixels.

__property int Width = {read=FWidth, write=SetWidth, nodefault};

 

 

Loading

copyright © 2007-2024  www.alciro.org  All rights reserved.         
Share |