PowerPoint Presentation by mJ9Vux5X

VIEWS: 0 PAGES: 6

									Unit 13 extra: BCB Controls, etc.
   Up Down Type Controls
       Integer Values: TCSpinEdit vs. TUpDown
       Non-integer: Using TCSpinButton
   Adding Global Functions
   Review:
       Locate() Function
       TDateTime
       TDBGrid
TCSpinEdit vs. TUpDown
   Goal: To change the size of an integer value
   TCSpinEdit in Samples component palette
       Key properties: MinValue, MaxValue, Increment
       Key Events: UpClick, DownClick
   TCSpinEdit is better than TUpDown
       Allow values greater than 32,767 (2.14+ billion)
       You can skip these steps needed by TUpDown
            Add TEdit control
            Set Associate property of TUpDown to TEdit
   BCB Help: TSpinEdit, TUpDown
Using TCSpinButton
   Advantage: Can increase/decrease any text
    value (not just integer values)
   Exercise:
       Add TCSpinButton (from Samples component
        palette)
       Add TEdit control to form
       Add variable: double myDecimalValue = 0.0;
       OnUpClick event:
            myDecimalValue += 0.5;
            Edit1->Text = myDecimalValue;
Global Functions
   Functions used by several forms and units
       Do not add the same method on many forms or units
   Instead, create a separate cpp unit
       File | New | Unit; Save as “Routines.cpp”
       Step 1: Declare function in Routines.h
            int square(int value1);
       Step 2: Define the function in Routines.cpp
            #include "Routines.h"
            int square(int value1)
            { return value1 * value1; }
       Step 3: In the form: Add unit header and call the function
            On button click:
            Edit1->Text = square(StrToInt(Edit1->Text));
Review: Locate() Function
   To find a record using composite key
       Declare an array of type Variant
       Set the array of values
       Locate using VarArrayOf() function (i.e., Variant Array)
   E.g., find order detail record
       TLocateOptions Opt;
       Variant OrderDtlArray[2];
       OrderDtlArray[0]= txtOrderID->Text;
       OrderDtlArray[1]= txtProductID->Text;
       DM->qryOrderDtl->Locate( “OrderID;ProductID",
        VarArrayOf(OrderDtlArray, 1), Opt);
   BCB Help (TCustomADODataSet), Slides 7 and Locate
    handout
Review: TDateTime and TDBGrid
   TDateTime: FormatString() method
       ShortDateFormat (“mm/dd/yy”)
       To specify four-digit year: “dd/mm/yyyy”
       Reference: BCB Help, TDateTime handout
   TDBGrid
       OnTitleClick: Access to current column
       E.g., ShowMessage(Column->FieldName);
       Reference: BCB Help, Slides 7

								
To top