User: alciro    User
 Original    Translate to:  Deutsch  English  Français  中文  
 

Programación en C++ Builder

 Arrays (arrays)
 Pointers
3. Example of class in c + +
8. AnsiString class methods
 C + + projects
 Packages, distribute an application without installation
 Exchange or bubble sorting
 String string.h functions

6.2. Derived TscrollingWinControl

These properties control the scrollbars of a form. If AutoScroll is set to true (default value) the bars automatically appear when the form is too small to accommodate all the components.

< br / > AutoScroll < br / > indicates when the scroll bars automatically appear when objects do not fit in the form.

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

HorzScrollBar < br / > represents the horizontal scrollbar.

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

VertScrollBar < br / > represents the vertical scrollbar.

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

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

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

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

   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. Derivatives of TWinControl

ClientOrigin < br / > indicates the coordinates on screen (in pixels) of the left corner, top of the client area of the 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 and coordinates in a record of type tagPOINT. The tagPOINT type define pixel location onscreen, with the origin in the top left corner of the control. X specifies the horizontal coordinate of the point, and specifies the vertical coordinate.

< br / > ControlCount < br / > indicates the number of controls located in a container control.

 __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 persona appears in the edit box controls.

 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 < br / > is an array of all the controls in a container control. < br / > Note: look at the example of ControlCount.

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

Ctl3D < br / > determines when the control can be seen in three dimensions (3-D) or two dimensions.

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

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

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

Handle

HelpContext < br / > provides the identifier of a form of context-sensitive help. If context-sensitive help is available, Windows displays the when F1 is pressed. The indicator serves to indicate to the help system which page of the help file should show.

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

ParentWindow < br / > Showing < br / > < br / >

TabOrder < br / > indicates the position of the cursor in the orders tab.

 __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 < br / > determines if the user can access control with the tab key.

 __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. Derived from TControl

Align < br / > determines the alignment of the control with respect to its container.

 enum TAlign {alNone, high, 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.
High 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 Governor 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 < br / >

Caption < br / > specify the text that identifies the control to use.

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

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";
} < br / >

Color < br / > specifies the background color of the control.

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

The following code changes the color of to 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 < br / > specify the image used to represent the cursor pointer when it passes through the region of the control.

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

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

Image used to represent the mouse pointer.

Enabled < br / > property that indicates when the control respond to mouse, keyboard, and timer events.

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

To disable to button called FormatDiskButton,

 FormatDiskButton - > Enabled = false;

Font < br / > controls the text attributes of the control. < br / > font used on the form. Font specified for the form is inherent in any component located within it (depends on the ParentFont property).

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

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

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

 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 < br / > specifies the height of the control or form in pixels.

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

Hint < br / > contains the text that appears when you move the mouse over the control.

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

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

"Name" The 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 < br / > specify the distance between the left side of the component and the container in pixels (coordinate X).

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

ParentFont < br / > determines when the control uses the source defined for its container and not yours.

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

This example uses a timer component and a label control. When an OnTimer event continues 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 continues 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 continues.

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

PopupMenu < br / >

ShowHint < br / > determines whether displayed or not the text that appears when you move the mouse over the control. < br / > see the Hint property.

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

Top < br / > specify the distance between the top of the component and the container in pixels (coordinate and).

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

Width < br / > specifies the width of the control or form in pixels.

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

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