273

Бобровский С. - Самоучитель программирования на языке C++ в системе C++ Builder 5.0 - 2001.pdf

  • Upload
    nika

  • View
    328

  • Download
    10

Embed Size (px)

Citation preview

  • .

    C++

    Borland C++Builder 5.0

    I-Press - 2001

  • .

    C++ Borland C++Builder 5.0

    I-Press

    .

    .

    ;

    :

    :

    :

    :

    :

    ISBN 5-93650-013-6 ( *)

    ., 2001 I-Press, 2001 , 2001

    00219 11.10.99. 10.11.2000. 70x100/16. . . . 17. . 1000. 1064

    , 105484. . , . 16- , . 21, . 1.

    199034, .-, 9 , 12

  • ? 11 ? 12 C++? 13 ? 14 Borland C++ Builder? 16 ? 16

    1. 18 Borland C++Builder 5 18 C++Builder 22 23 Borland C++Builder 25

    C++Builder 25 26

    ? 26

    27 27

    (Object Inspector) 28 28

    28 31

    31

  • 2. 34 34

    34 34 35

    Edit ( ) 35 Label ( ) 37 Button ( ) 38 38 39 40 40 ? 41 ++ 42 43 44 ? 45 C++Builder 46

    47 49 ++ 50 52 52

    52 55 56 57

    57 59 59 61 61 , 63

    float 64 double 64 long double 64

    65 67

  • 67 69 70 71 74 79

    3. 80 80 81 83 85

    4. 86 86 86 ? 89

    5. 90 90 90 93 94

    6. 96 96 97 99

    7. 101 101 102

    102 102 103 106 107 108

  • 8. . ? 110 111 111

    111 112

    115 117

    118 118 118 119

    119 119 120 121 122 123 125

    125 127 130

    9. 132 - 132

    133 134 135 137 138 139 141 141 142 144 145, 145

  • 146 148 149

    149 151 151 151 152

    153 153 154 155 156 158

    159 159 159 161 ++ 162

    10. 163 ? 163 164

    164 165 166 166 167 168 170

    170 ? 170 171 171 ? 172 174 175

    176 177

  • 178 179 179 180 181 183 185 186 187

    187 187 189 191 192 193 194 -2 199 ? 200 200 201 202 203 204

    208 213 214 215

    1 1 . 217 ? 217 ++ 217 218

    218 220 220 222 224 224 226

  • 229 C++Builder 232 233

    12. , 233 235 Standard 235

    235 235 236 236 236 236 237 238 238 238

    Additional 239 239 239 239 240 240 240 240 241 241 241 242

    Win32 242 242 243 244 244 244 245 245 246 246

  • 247 247 247 248 248

    System 248 248 249 249OLE- 250

    Dialogs 252 ! 253 C++Builder 255

    255 255

    13. 262 Borland C++Builder 262

    262 263 263 263 263 264 264

    266

    10

  • ? , ,

    , -

    Windows, . 400 ,- ,

    ,

    , .

    {) -. ( -), , , .

    , , -

    , , ,

    , :

    ;

    ;

    ,

    ;

    .

    , -

    . ,

    .

    11

  • ? ( - , ), , -

    . , -

    .

    , , -

    .

    - . ,

    -

    , .

    , ,

    ,

    .

    ,

    ! - .

    .

    . -

    ,

    . , ,

    , .

    :

    ,

    : .

    .

    , -

    . , -

    . ( Borland C++) - . ,

    , ( ), , - -

    , ,

    . ,

    .

    12

  • C++?

    , , -

    . -

    , ,

    , .

    , -

    , . ,

    .

    ,

    . :

    -

    .

    , .

    . -

    , ,

    3 0- 20-, , .

    , -

    , .

    . -

    , ,

    , :

    ,

    ( >

  • _ ^

    .

    , ++

    , , , , ,

    , , . ++ -

    .

    ++ . -

    , .

    , Windows ++.

    ? ++ -, , , .

    , -

    .

    .

    , ++ Windows. ++, Windows .

    ,

    , , , -

    . Windows , , -

    .

    -

    .

    Windows, -. . -

    ,

    , .

    ,

    ++, , - .

    ,

    ++ - .

    14

  • , ,

    Windows Linux.

    .

    ++ Windows, ! , .

    (, . .) ( ), .

    , ,

    .

    (RAD-), , , -

    -

    , .

    , , , ,

    Windows ( RAD- - ), - .

    . RAD- :

    , ,

    .

    , -

    :

    ;

    ;

    ;

    - ,

    , -

    .

    RAD- --. , , , -

    .

    15

  • (- , ,

    ) , - ! , - Windows, , -

    .

    , -

    .

    (, -) . , shareware-. -

    , .

    Borland C++Builder? Borland C++Builder, 2000 , -

    ++ Windows. 200 , -

    . Borland C++Builder MicrosoftVisual C++, RAD-,a Microsoft Visual Basic, . , C++Builder, , MS Visual Basic. C++Builder .

    RAD- Borland Delphi, , C++Builder. Delphi C++, , - -

    ObjectPascal. , Borland C++Builder ++, !

    ? , RAD-, -. 500 -, 32 .

    16

  • ?

    , , -

    , (- ++ ) .

    Windows 95 Windows 98, - Windows NT. ,

    Windows 9x. -, -

    , , ,

    .

    Windows NT, - C++Buitder - , . ,

    , Windows 98, Windows 98, , . , , -

    C++Builder, Windows 9x Windows NT.

    , .

    C++ . , - ,

    , -

    .

    :

    17 , 1024x768.

    :

    15 , 800x600.

    :

    15 , 1024x768.

    17

  • 1.

    Borland C++Builder 5 Borland C++Builder, () . .

    1. . Borland C++Builder . , , - -

    , Windows . instalt.exe - .

    2. - ( C++Builder ). - C++Builder (. . 1), , - , 543 ( - ).

    3. C++Builder . -

    .

    4. - , Next ().

    5. - Next() .

    18

  • Borland C++ Builder 5

    . 1. 6. -

    . ,

    C++Builder 5, , . -

    , ,

    , .

    , Yes .

    7. , Next()...

    8. ... : (Typical); (Compact); (Custom); (Full).

    (Typical). .

    (Compact) -. (Custom)

    19

  • 1.

    , -

    , .

    (Full) , 550 .

    , -

    .

    9. , Microsoft Office (MS Office 97 MS Office 2000) C++Builder , Word, Excel . .

    10. (- ) - (. . 2).

    . 2.

    11. , - ,

    . ,

    ,

    Install VisiBroker For C++Builder.

    ,

    () InterBase. ,

    20

  • Borland C++ Builder 5

    , -

    Install InterBase Client.

    , ,

    . , , -

    ,

    :

    / , /, / , /, $ -

    , , -

    :

    Pentium II/450/64/10/500

    , ,

    , ? ,

    (). - ,

    Borland C++Builder.

    12. Next (), - . -

    .

    ,

    Agree ().13. (. . 3) , -

    C++Builder. - Browse (), . , -

    C++Builder, .

    -

    Inprise (, Borland Delphi), - , .

    , -

    , .

    C++Builder , - (Req:) (Avail:). , Next ().

    21

  • Select Component Directoriesleas t Ihe location where you would Sfce to install thejrogtam

    Bjovgse..gram rilesICVPmgramFiles1.sred files.e \laigsv3etnfi\I and S6L Links

    Req: 315159 .

    R*q:6742K ".Borland Shared

    e- MangsSdelph-^E ortand S haiec^BDE1 abase Desktop Req :3831

    Avaa:2323BK

    Avail :S4574

    Avail :84574

    Avail:292^)6KCAPsegtan Filss\Bo-lndTat2base Desktop

    Infu... Cancel

    PMC. 5. 14.

    ,

    C++Builder . - , Next ().

    15. - Install () .

    . , -

    10 . readme.txt C++Builder. - Next ().

    16. . Finish () Windows.

    C++Builder, .

    Borland C++Builder Borland C++Builder 5.

    22

  • C++ Builder - , .

    Help, .

    -

    (IDE) . . BorlandC++Builder 5 (. . 4):

    C++Builder;

    (Object Inspector); ;

    .

    .-'* i Builder - 1 tf.' Search iew ErajecJ B-r> icmocsit Qetobase j.cals help jJJ'' _|2 & ' Q e ^ S l ^ b f ' ^ 5tMiard j Addliaiai ] ^r,321 Swterr 1 Da's ! - Zoriinl* . i l l .

    a l lP'OBerhes | Eventi jAckm

    AiQfi

    buefaisa

    -o'-i233S

    [T SizaCcnihw ^ jMadided Insert

    . 4. IDE

    2 3

  • 1.

    , , :

    (Class Explorer); .

    Uniti cpp

    Project! -Classes cpp

    5 S

    j#prsga hdcstop

    -j^mclude "UnitI. h"| / /

    :'j#pragiaa package smaKt_ir,iL);#pr&gitia r e s o u r c e ' " .df tn"ITForral *Foriul;

    f a s t c a l l TForml: :TForrfll(TCoHiponent* Owner)

    4 JfModifflsd* Insert

    . 5-

    . -

    , -

    ,

    .

    , ,

    . -

    . ,

    ,

    , .

    , ,

    C++Bui'lder C++BuUder Direct. ,

    Web- Inprise (www.inprise.com), , Borland C++Buuder -

    . .

    24

  • Borland C++Builder

    Borland C++Builder C++Builder ,

    . .

    :

    ;

    ;

    ,

    ;

    Buildor 5- Project]'f* Edit Seordi Erojact Ban jjatabese

    ^ Wb32|U Q'

    la Centred

    ,

    , .

    .

    Standard Sw*tem| Data Access! Date Controls

    , -

    .

    , :

    Standard Windows;

    Additional , Windows;

    Win32 Windows 9x; System (,

    ); Internet , ;

    Data Access ; Data Controls ;

    25

  • ] .

    ADO Windows- MicrosoftActiveX Data Objects (ADO);

    InterBase InterBase Inprise;

    Midas , ;

    InternetExpress Internet ;

    FastNet , , ;

    Decision Cube ;

    GReport ;

    Dialogs Windows;

    Win 3.1 Windows 3.1;

    Samples , ;

    ActiveX ActiveX- (ActiveX -, Microsoft. Borland C++Builder 4 );

    Servers , Word, Excel, PowerPoint, Outlook .

    ? Windows, (, , , , . .). ,

    Windows , - .

    .

    SHIFT+F12 .

    26

  • -

    .

    ( ). , -

    . , ,

    C++ Builder .

    ,

    .

    . , , -

    Button .

    ( ) , ( ) .

    , , -

    ,

    .

    ,

    ,

    .

    , .

    C++Builder - Windows. , ,

    . ,

    NMPOP3, ,

    MicrosoftOutlook Express. , - Web-. ,

    ().

    .

    .

    .

    27

  • . -

    .

    Word , , -

    .

    C++Builder , , - ,

    .

    (Object Inspector) . -

    -

    .

    , ,

    , , ,

    , . .

    , ;

    ( ) . . ,

    , -

    .

    -

    F11.

    -

    , .

    , ,

    ,

    Windows. , - , , -

    . .

    28

  • ,

    . ,

    Button 1 !, - , -

    OnClick () Button 1. ,

    Edit 1 , OnChange (). - , Editi .

    .

    .

    , ( ) . , ,

    .

    :

    (Properties) (Events), , , -

    . -

    ( ), . -

    C++Builder. , , , , -

    . -

    , .

    , Autosize - , false (, -) true (). AutoSize true.

    Autosize , -

    .

    -

    . , ,

    Fortnl TFormlPlopeitwj ] EvAtftveContm!

    ' AutoSiie' _B>Mode

    SordecSMe

    "CteriWiifc

    2 hidden

    sritsf

    fefee

    fesSeeatJeaFormi2E9338

    .d

    !

    A c t i o n

    Altgn

    AutaScroSA t i o S e e

    B S o r d e t f c o m

    BcsdefWicfthCaption

    C c t o r "

    alNotse

    truet i u e r

    j fa lse

    "a

    i Q e B t r f a c e

    29

  • 1.

    BorderWidth, 5.

    , ,

    - , -

    .

    , , ,

    Borderlcons. + . ,

    Borderlcons , - . -

    BorderWidth .

    , -

    . , -

    , Font (), , -

    . ,

    BorderWidth, ,

    . , ,

    Height ( ) -11. , Font Style ().

    DtagModeEnabled

    BFortCbaisetColorHeightNamePilchSee

    StyleFormStyleHeightHefcConterfHeipFIaHint

    jdmManual *MruelUSBK ZJ

    .DEMULT^ CHi'dutadowTt

    'MS Saris Serf'jpDefauR'j]tsSojmal,300a

    JBuOop

    j ^ H 2 Hajop .1

    . . - Font ()

    30

  • . - , -

    . ,

    , ( ), -

    . - | - *

    . -

    -.

    Font Windows .

    OnCpmtrainedf

    OnAcbvsteOnCanResaeOnCiose

    OrContextFopiDnCreataOnDWCtekDnDaacbvacaQnDestroyOnDockDropOnDockQver 'QnDragOropOiCragOver

    (Events) - , , -

    .

    -

    .

    (. . 4 5).

    F12. , , :

    ++. -

    . .

    .

    (. . 7). ++,

    . , C++Builder .

    -

    ,

    ! , -

    95% - .

    3 1

  • cHt )mw Project Btm Somponent Qatobase Tools jjelp |||Daia CsntWfe 1

    . i nc1ude hdrscop

    ;#include "Unit i .h"I//;#pragws package (smart ir.it)-^pragma resource " s.dfm"iTForiml *Forml;

    .TFormi -Uniti .h (11)1: :TForral (TCotnponenc11 Owner!

    : TFocrn [Owner)

    i i o , , 10:40. 7.

    Windows ,

    .

    ,

    . ,

    , O+Builder. - !

    ++, -

    .

    .

    ,

    ( , TForm 1) . , (11) (Uniti.h) TFormi.

    32

  • .

    . -

    , Properties (), Code Insight (), Tooltip symbol insight ( ) .

    ,

    . Word , - ++ .

    2 3 3

  • 2.

    ,

    . , Borland C++Builder , Windows . . -

    ,

    . Borland C++Builder - .

    .

    .

    ( ), - . , ,

    Windows ( ) -, Windows - ( ). .

    .

    , ,

    ( -), . . ,

    34

  • Edit ( )

    ,

    , -

    , .

    .

    , , .

    , .

    , -

    . - , -

    , ,

    .

    , ? . - Borland C++Builder, - , -

    .

    : -

    .

    , , -

    .

    Edit ( )

    Edit

    ( - F12). ( Standard) , , . -

    Edit.

    -

    . Edit!

    ,

    , -

    .

    , -

    .

    ,

    -

    ,,-' Hoiml

    35

  • 2.

    .

    , , . -

    . .

    . . , -

    ,

    .

    , , .

    . ,

    , -

    .

    . , .

    -

    Edifl. , Edit2 .

    ,

    . ,

    , . -

    , ,

    .

    1, Edit 1.

    2. Properties ().

    3. Text (). , - .

    , ,

    . -

    , .

    4, Text () Edit 1 0 ( , , -

    , ).

    [Object InspectorJEditl TEditProperties j verts|

    j~ ParentBSiModTtrue' PaentColoi PaientFont' PaientSfiQwHs! PasswofdC3iai| PopupMenuI ReaciQrty, TabOrde| TabStopi ^aqI

    Tap' Vsibte; WkMij*2 hidden

    iiueSuem

    false0Hue0

    32hue121

    EEI

    i 3

    36

  • Edit ( )

    Text -. .

    Editl ( Name -) ( Text). -, , .

    , ? . Name () Editl Dollars. C++Builder .

    Name C++BuiLder. , -

    .

    , -

    , .

    , ,

    , Rate ( ), - 0. .

    Label ( ) -

    ? Labal

    . ,

    ,

    ,

    .

    (Label) . Label 1 Text , - . ? - Caption (). C++Builder.

    Label 1 Caption . . ,

    Label 1 AutoSize ( - ). - , AutoSize, True False.

    37

  • 2.

    . 8.

    True False ++, C++Builder. True - , , . False - , , .

    , (, . 8), .

    , .

    Button ( ) ,

    . Button -, Label 1, , , TotalButton ( Name), > ( Caption)., .

    , . -

    , ,

    ,

    TotalButton.

    , -

    . , -

    .

    , , -

    . , ,

  • . , -

    , .

    , . -

    , . -

    .

    Save All ( ). , ( ++ .). Uniti.

    Save Uniti Projects

    2} Lib

    : (

    : jC~+Builcer unit (".]

    . 9.

    Calc, . , (.BPR), , . CalcProject .

    -

    ++, . :

    .

    39

  • 2.

    .

    ,

    , , , -

    ! ++, , , ,

    , , .

    TotalButton. - , ,

    ,

    , ,

    TotalButton.

    -

    ++. , .

    {...}, . ,

    .

    , -

    .

    , ,

    Dollars Rate, Label 1. Dollars - - . ?!!

    .

    : , , ,

    , , (- , ) .

    , , -

    . , -

    .

    40

  • ?

    ? , ,

    ( -). , , . -

    , -

    . ,

    .

    , ,

    , -

    : Undefined symbol . , - .

    , , -

    ,

    .

    {...} . -, , -

    , ( ). ++ - , _.

    .

    ++.

    CatListBoxWindows99ge33iv5HsY8Ys

    ilOO

    ++:

    ( );f o o t b a l l game ( );1 ( ).

    41

  • 2.

    .

    ++ :

    ----;

    8 ++ ;.

    . DollarsNum. ++ , int (- integer ). - :

    { i n t DollarsNum;

    ++

    ++ . -

    . ,

    , ,

    . , -

    , int.

    ++ . , int Int , int , Int .

    Borland C++Builder

    ,

    . , i n t DollarsNum; aimt Dol 1 arsNum;, imt ( - C++Builder , ), , .

    ++ .

    , C++Builder . , ,

    (Edit) TEdit. , C++Builder -

    42

  • , ,

    TFormi. , , .

    DollarsNum, - Dollars. , DollarsNum , number_of_dollars dollars, .

    , ,

    -

    , , -

    . , C++Builder -

    ( , ). - . ,

    Microsoft Visual C++ (Class,).

    DollarsNum . - RateValue, - .

    :

    i n t DollarsNum;i n t RateValue;

    :

    i n t DollarsNum, RateValue; DollarsNum, RateValue int. . :

    i n t RateValue; i n t DollarsNum; :

    i n t RateValue, DollarsNum;

    .

    43

  • 2.

    , ,

    , .

    , - ,

    ,

    , .

    .

    , , ,

    . ,

    -

    .

    /* , */ .

    .

    :

    /*

    .

    *//* */

    , -

    , .

    //. // .

    DollarsNum :i n t DollarsNum; //

    ,

    , ,

    .

    . -

    . :

    i n t DollarsNum; // DollarsNum . ,

    . :

    44

  • ?

    /* DollarsNum RateValue */

    :

    /* */ Result, - :

    int Result ;

    -

    ++, - , ,

    . TEdit. , TEdit , .

    :

    i n t DollarsNum;i n t R e s u l t , DollarsNum, RateValue;

    : Multiple declaration for ( - ), , DollarsNum .

    ? , -

    . ,

    DollarsNum RateValue.

    Windows C++Builder . DollarsNum RateValue, , .

    , , , int, .

    , TEdit : , ; , -, . ++ .

    45

  • 2.

    ++. Windows ++. , -, ,

    .

    . , -

    TButton. Windows C++Builder .

    ,

    .

    , -

    . , , -

    TButton, :

    TButton my_button;( C++Builder -). ( , ) - .

    ,

    . ( ) TEdit Dollars, , -

    , ,

    .

    ,

    , .

    Dollars? Dollars ( -) TEdit ( Edit ). ,

    , ,

    TEdit.

    C++Builder ++.

    , -

    C++Builder (Edit Label Button ), -.

    -

    46

  • ?

    .

    , :

    int Edit Label, Button;

    int TEdit;

    int TLabeL;.

    , TEdit Text. , , DollarsNum 12 3, Text , .

    ,

    . ,

    , . -

    , .

    ? . , , ( ,, ) . Dollars, Rate, TotalButtom, , Name (). . , , -

    . ,

    , ,

    , .

    , Name . ,

    Name Dollars ( , !), . Dollars. >, - , Name. :

    Dollars->Name

    Rate,

    Rate->Text

    47

  • 2.

    .

    , Caption Label 1

    Labell->Caption

    ( ),

    , .

    Name TEdit ( Edit), ,.

    , , 100, 100, C++Builder.

    C++Builder ( ) - . , -

    .

    , .

    -

    ,

    , , .

    ( ) , , .

    StrTolntO {StrToInt - String To Integer). . -

    , , . StrTolnt(), , int ( ).

    ? . ? , , . - ( - ,

    ). . , . StrTolntO - int.

    ? ++ , , ( ), -

    48

  • . -

    , .

    . , StrToInt . ,

    .

    StrToInt StrToInt Dollars. , , Dollars>Text, , StrToInt :

    S t r T o I n t ( Dol lars->Text )

    , StrTolntf) Dollars . ?

    , -

    , .

    , ,

    ++, . -

    (, , - ).

    ,

    . ,

    , .

    :

    = ;

    ,

    I = 10;

    I, , :int I;

    DollarsNum , - StrTolnt(). , , :

    DollarsNum = S t r T o l n t f Dol lars->Text );

    49

  • 2.

    RateValue :RateValue = S t r T o I n t ( Rate->Text );

    . -

    . -

    ,

    ++ , - :

    Text,

    D o l l a r s - >Text

    -> {) ++, , = () - (-

    50

  • C++

    ). , . ++ , , , =.

    .

    :

    Dollars -> Text

    Dollars-> Text

    Dollars ->Text

    Dollars

    ->

    Text

    . -

    ( ). . ,

    Result = DollarsNum * RateValue;

    :

    Result=DollarsNum*RateValue; , -

    , ( ):int Result;DollarsNum=StrToInt(Dollars->Text};

    , -

    . :

    i n t R e s u l t ; , ,

    int . .

    .

    -

    .

    51

  • 2.

    , -

    Result. (, - ), Label!. , Text, Caption, . ,

    , Label 1.

    Caption? . , , -

    . .

    Result , Caption -. ? lntToStr(), , . :

    L a b e l l - > C a p t i o n = I n t T o S t r f R e s u l t ) ; ( , ) :

    {int DollarsNum, R a t e V a l u e ;

    int R e s u l t ;

    D o l l a r s N u m = StrToInt( Dollars->Text );

    R a t e V a l u e - StrToInt( Rate->Text );

    R e s u l t = D o l l a r s N u m + R a t e V a l u e ;

    L a b e l l - > C a p t i o n = IntToStrf Result );

    }

    ++ , . -

    .

    ++ - ,

    .

    .

    52

  • Add tc Project Shift+F* 1emcvg from Project..

    ^ Import Type bibrejy..(* And lc Repository..J5| View SDurca

    Lenguagss

    Alt*F3T5 onpite Unit

    Information for Ca:cProject' Maks Ail Projess*5 Build All Pro-.BBs

    Save All (- ) Project MakeCalcProject ( CalcProject) CTRL+F9. C++Builder Background Compiling (), . 10, .

    C++Builder 5 - . -

    , -

    , -

    . -

    Windows, . -

    , , -

    , ,

    . ,

    Tools Environment ( ) Preferences () Background Compilation ( ). Project () , Compiling (-) ++; Current Line () , , ; TotalLines: ( ) , ++.

    options. 3hflCtrl*F11

    . 10.

    53

  • 2.

    Errors: (), Warnings: (), - Hints: (). C++Builder , ,

    . ,

    DollarsNum RateValue, RateValue -, :

    int DollarsNum, RateValue;

    int Result;DollarsNum = StrToInt{ Dollars->Text );Result = DollarsNum * RateValue;

    RateValue , .

    , -

    .

    . , -

    , - . -

    ,

    R e s u l t = 2;R e s u l t = DollarsNum * RateValue;

    R e s u l t = 2;

    , Result - 2, DollarsNum *RateValue.

    . -

    ,

    .

    () , - ,

    .

    -

    .

    C++Builder , , -

    54

  • (). , -.

    ,

    . , , -

    , , ,

    , .

    , -

    ,

    ,

    .

    .

    .OBJ. . , Calc.cpp Calc.obj. . Calc.exe.

    .

    ,

    StrTolnt(). , - LIB ( - Library ). , -

    ,

    .

    , -

    Windows. - , , ,

    ,

    ++.

    , Compiling () - Linking (). , - , Borland C++Builder . -

    . , -

    , , ,

    .

    55

  • 2.

    ,

    .

    , -

    - (Linker). . ,

    -:

    . . -

    ,

    C++Builder Done: Make, . , -

    , .

    Done: There are errors , , - -

    .

    .

    , .

    , . -

    Compiling (), , Run () - F9. Borland C++Builder - . ,

    . 11.

    Ifj-ormi

    "5

    . 11.

    100 (100 ), 30( 30 ), >. , - , 3000 . - . 12.

    56

  • . 12.

    . -

    . ,

    Windows Borland C++Builder, -, - .

    , , :

    , . -

    .

    -

    . Label ( ),

    . ,

    Label 1 - Delete () Label 1 . Edit ( ). Roubles. ,

    . C++Builder , , ,

    . , ,

    , Caption - Label 1, , , Text Roubles:

    Roubles->Text = I n t T o S t r ( R e s u l t ) ;

    57

  • 2.

    -

    . -

    ,

    -

    . ,

    .

    Dollars Rate , - .

    ConvertButton, Text );RateValue = StrToInt( Rate->Text );Result = RoublesNum / RateValue;

    Dollars->Text = IntToStr( Result );

    }

    -

    Dollars.

    ,

    , -

    . ,

    - , -

    . ,

    58

  • Result = DoliarsNum * RateVaLue;

    DolLarsNum HaRoubLesNum * - /, , ,

    , , , , ,

    .

    Result? , TotalButton, ,

    .

    , ++ , , .

    , -

    .

    ,

    , ,

    . , ,

    {...} , . . -

    (, ) - .

    Result , .

    . , Form 1, .

    Calccpp. .

    ( , C++Buitder ). - -

    , ,

    ,

    .

    59

  • 2.

    -

    , ?

    , . , -

    ,

    ,

    . -

    , -

    , .

    :

    // {//

    int T;

    = 1;

    {// float ;

    - 3.14;

    }// // 1

    {// double ;

    - 3.3333;

    {// int T;

    = 50;

    }// // 3.33

    }// // 1

    } // /*

    */

    60

  • F9 ( ). C++Builder , ,

    , .

    , -

    .

    3 0 ( ), 3 000 ( ),

  • 2.

    , Pentium 32-. ? , - , 0 23 2-1, 0 4 294 967 295 ( ++ , unsignedlong). , - -2 147 483 648 2 147 483 647.

    ++ - . -

    , Borland C++BuiLder.

    , , .

    . C++Builder , , int64, -9 223 372 036 854 775 808 9 223 372 036 854 775 807. .

    . -

    , int64, i64, :

    3000000000i64

    !:

    30000003000000000164

    :

    3 000 0003,000,000

    , - ?

    ++ , - C++Builder ( ), (!):

    int i ;i = 3000000000;

    ?

    62

  • ,

    3000000000 int -1 294 967 296. , , -

    , !

    , ,

    , 3000000000, 4 294 967 296 2.

    ++ . , -

    , , , , -

    . ,

    ++ , ,

    .

    ,

    , ,

    -

    ?

    ,

    , , .

    ++ . .

    ;

    . 67+24 0 . 66+25

    , ( );

    ;

    , -

    ,

    ; + .

    :

    3000000000 = 910 - 11

    0.03000000003 = -12

    63

  • 2.

    , , ++, -

    , -

    .

    ++ (- , , -). , -:

    123.451.234521 2 3 4 . 5 - 1

    , () , .

    float ++ float (- ). 1.18-38 3 .438.

    ?

    , 38 . , .

    , -

    120 .

    double double (- ), 2,23~308 1.798.

    long double , -

    120 . , - . ? -, C++Builder long double ( - ), 3 . 4-49321.24932. .

    64

  • .

    , 7-10 , 1,23456789 1,234567412 . . float double , ,,

    float. , ,

    . , ,

    , , -

    .

    ++ -

    , ,

    .

    , .

    , ++ -

    , 80- , .

    , ,

    ++,

    ,

    , ,

    .

    . int float. ,

    .

    .

    Replace All ( ). CTRL+R, ,

    , . 14.

    Text to find: ( ) i n t , lntToStr(), Replacewith: ( ) : f l o a t ( ), Origin( ) Entire scope ( ) Replace All ( )., :

    65

  • 2

    (Replace Text

    " sensitive" i*$mie words only

    " on feolace-Scoper-

  • . -

    C++Builder, , , lntToStr(). , -

    , -

    , :

    int m;m = ( i n t ) 3 . 1 4 ;

    , m

    3.

    , .

    . :

    float x; = 5; //

    , ++ , -

    . , -

    , , float double( ).

    :

    int N ;N = ( i n t ) ( 5 . 5 + 4 . 4 ) ;

    ( 5 . 5 + 4 . 4 ) , 9,9, - int ( 9, ).

    , :

    int ;N = ( i n t ) 5 . 5 + 4 . 4 ;

    ,

    5.5, .

    67

  • 2.

    ++ , ( ).

    2*2 + 3*3 ,

    . ++ - , -

    , .

    ++ , . ( i n t ) 5 . 5 + 4.4 5.5 + 4 .4, 9.9 int.

    ,

    . -

    2*2 + 3*3 , - (int)(5.5 + 4.4).

    . -

    ,

    , -

    .

    , lntToStr

  • , , ++ , -

    Borland C++Builder, Windows, - .

    Windows , WindowsWIN.INI, [intl] sDecimal. - Windows . , Windows , :

    sDecimal-, -

    , .

    , -

    Windows, ++, .

    25,5 ( 25.5). > 2550 (). 29,9 ? - ?

  • 2.

    ;

    ( ), - ; ,

    ffFixed;

    , -

    ( ) , - ( , 10 - ); , ,

    .

    . ++ . ,

    Windows C++BuHder,,

    Windows. FloatToStrF() -

    , .

    , -

    .

    , -

    , -

    . ,

    C++Builder .

    :

    Roubles->Text - FloatToStrF(Resul t , f fFixed,10,2) ;Dollars->Text = FloatToStrF(Resul t , f fFixed,10,2) ;

    , , , 1000 30 33,33.

    , ,

    . ,

    . , 9,9 , 9 .

  • , C++Builder , - . f!oor(), , -

    (int). , .

    , :

    f l o o r ( + 0 . 5 ) .

    ,

    : Result - .

    :

    // :R e s u l t - f l o o r ( DollarsNum * RateValue + 0.5 );// :R e s u l t = f l o o r ( RoublesNum / RateValue + 0.5 );

    .

    : Call to undefined function floor ( floor). ? , , ?

    , , f loor() . .

    (LIB-), ( , / . .). C++Builder . , -

    , ,

    ?

    , ,

    , , floor(). . Help Contents ( ). Index () : f l o o r (. . 15).

    71

  • 2.

    floor, floor!

    Headei Filemath.hCategoryMath RoutinesSyntax#include

  • : Header File . . ,

    (math.H). . . ( .). .

    , ,

    ,

    .

    , .

    . -

    , ,

    . . -

    , floor() :double f l o o r ( d o u b l e ) ;

    . -

    -

    .

    , , floor() :

    double f l o o r ( d o u b l e ) ; math.h , f 1(), . ,

    , , -

    , .

    ?

    :

    # i n c l u d e - >

    # i n c l u d e "-"

    ,

    -

    , ,

    ( C++BuiWer).

    73

  • 2.

    ,

    .

    :

    # i n c l u d e math.h.

    .

    Calc.cpp. vcl.h (- Visual ComponentLibrary) Calc.h, . math.h vcl.h:

    # i n c l u d e # i n c l u d e

    ( F9), 1000 30 33,00. ,

    FloatToStrF{) , - , , .

    , . -

    , ,

    :

    .

    1. . , - . -

    ,

    8 ( ). , Tools Environment Options ( > - ) - C++Builder (. . 17). Preferences (), Grid size X: ( ) Grid size Y: ( ) , -, 5. , .

    74

  • Lnvironmorvt Options

    Cancel Help

    :. 17. 2.

    .

    , , .

    ,

    .

    . , -

    .

    -

    -

    ,

    Align to grid ( ).

    .

    3. . ,

    Align (-). .

    Creation Order...' .Rip Children ' . >Addta ftepci&rtory.,.yiewasTexiTextPFM

    . -

    (Horizontal), - (Vertical). , -

    75

  • 2.

    [Alignment

    -Wli

    ghmft to smallest

  • -

    , 50 . - .

    5. ,

    .

    Ok -

  • 2.

    , .

    6. ,

    . , . 3, Align () Spaceequally ( ) Horizontal ( ).

    .

    ,

    Center in window ( ).

    (. . 20).

    ! 3 1 InseH

    PMC. 20.

    7. , , ,

    . ,

    , .

    (-, Label).

    78

  • , -

    (. . 20).8. -

    Form 1, Borland +Builder . ,

    , -

    Caption .

    . .

    .

    . , , ,

    Calc. 14 , - C++Builder. , , , .

    .

    .

    .

    . , ,

    , .

    Windows -. . :

    :\WINDOWS\SYSTEM\sheI132.dll:\WINDOWS\SYSTEM\pifmgr.dll:\WINDOWS\SYSTEM\moricons.dll:\WINDOWS\SYSTEM\progman.exe

    .

    , -

    , -

    . ,

    , -

    C++Builder, 24 !

    79

  • 3.

    ,

    . C++Builder File Exit( ) , - CalcProject, C++Builder . ,

    . File Open Project ( ) ( CTRL+F11), - CalcProject File Reopen ( ), -, (. . 21).

    f.-'C++Buildor Edit earch yiew grqed Bun Component 0afabase Icrals. Q blew f; Siarafad j Adjuonal I Wm32 ! Swieral **)

    A fSST

    80. 21,

  • . 0, -

    ,

    .

    ( F9) , -, 1000. ( , ). - , C++Builder (. . 22).

    Project CalcP"3JBc?.e*B raisae exception classEZeroZiNiie sdi rreseaga 'Floating byzerc'. Prccass stopped Use Step crRt-nto '.^.

    OK

    . 22.

    }' ? , RoubiesNum ( 1000) RateValue ( 0). , ! , -

    , -

    . ,

    .

    Calc cpp

    // . __, _*-._____,void fas tcal l TFornil: :ConvertButtonClick(TCtoject "Sender)'(float RoublesNum, RateValue;float Result;RoubleaNum - StrToFloat( Roubles->Text );RateValue - StcToFloat( Rate->Text );

    DollaE3->Text - TloatToStrF( Result, J lxed, 10, 2

    i L J43 1 "itnsert

    . 23. ,

    81

  • 3.

    , C++Builder , , ,

    (. . 23).

    .

    ?

    ,

    . , ,

    , , -

    .

    -

    . ?

    -

    , -

    , ,

    Windows, ( ).

    , . F9, , -

    Floating point division by zero ( ), . 24.

    iC;jlc|)rojec)Floating point division by zero

    , 24, ,

    ?

    . C++Builder , . .

    -. , , ,

    , -

    . ,

    Calcexe C++Builder, Windows, ,

    82

  • . , -

    , .

    , (, ). "" is not a valid floating point value ("" - ). , -

    C++Builder.

    C++Builder , . ,

    , -

    .

    . -

    , , ,

    .

    F5. - , .

    0,'ilc cpp

    > ivoid fastcaJJL TFctrnl : ConvertButtonClicfc [TOb ject 'Sender)Text );RateValue = StrToFloatf Rate->Text ); J

    Dollar3->Texc - FloatToStcFf Result, Fined, 10, 2

    Puc. 25.

    {Breakpoint).,

    , ,

    .

    83

  • 3.

    | , ^ , ,

    .

    .

    F5 .

    , 1000 () - . , -

    , ++, . .

    RateValue, , (. . 26). , ? , RateValue ,

    .

    View Erajsct Qm omponent

    . 26.

    84

  • . -

    , ,

    CTRL+F2 ( Run ProgramReset), C++Builder , -

    . .

    , ?

    , , C++Builder , - , , -

    .

    Source hat been modified, ftefctutid?

    No (), -, , ,

    ++ . , -

    , C++Builder , . ,

    ,

    .

    .

    CTRL+F2.

    85

  • 4.

    , , -

    -

    . ,

    , .

    , , -

    . , -

    Result, DollarNum StrToFloat ( DollarsNum). RateVafue, . -

    :

    Result = floor( StrToFloat( Dollars->Text ) * StrToFloat( Rate->Text ) + 0.5 );

    StrToFloat ! :

    f loat DollarsNum;f loat RateValue;f loat Result;Result = floor( StrToFloat( Dollars->Text ) * StrToFloat

    ( Rate->Text ) + 0.5 );Roubles->Text = FloatToStrF(Result, ffFixed, 10, 2 ) ;

    ( CTRL+F9). , Done: Thereare warnings ( ). ?

    86

  • C++Builder , Project Project Options( ), Compiler () - Warnings () - AIL ().

    Compilingftqec*- 0 ^twoikitetDC:teftoiBct tpDone. Then: ore wommg.Cuiranllme: 0 ^Totalities 173

    S Waning^ 4 * QHuts

    . 27. Warning

    . -

    , -

    , (. . 28).

    void f astcali TFptml: :TotalButtonCiicK (TObject

    float RoublesNum;float RatEValue;float Result;

    Result = floor ( StcToFloatf DollaL3->Text ) * StrToFloat[ Rate->TexRouble3->Te>:t = FloatToStrF( Result, ffFixed, 10, 2 );

    [C++WerningJ Celc cpp(25). WB080'RateValue' is declaied bul never used[C*+ Warning I C ale cpp(25t' W80S0 'RoublesNum' is declared but nevei used[C Warning] Caic.cpp[25J WS057 Paiameter 'Sender' never ured[C+4 Waning] Calc cpp[4G] W6057 Parameter 'Sender' is never used

    25 I Insert

    Puc. 28.

    -

    ,

    . .

    "RateVafue" is declared but never used "RateValue" , . , ,

    8 7

  • 4.

    RateValue ( DollarsNum) . -

    ? - , RateValue . , -

    .

    Parameter"Sender" is never used ( Sender ). , Sender TotaLButtonCLick ConvertButtonClick . -

    , , ,

    -

    C++Builder .

    Compiler Warnings Selected () Warnings . ,

    , , -

    .

    , :

    f loat Result;Result = floor( StrToFloat( Dollars->Text ) *

    StrToFloat( Rate->Text > + 0.5 );Roubles->Text = FloatToStrF(Result, ffFixed, 10, 2) ;

    -

    Sender.

    ? Result .

    Result f 1():Roubles->Text = F l o a t T o S t r F ( f l o o r ( S t r T o F l o a t

    (Dol lars->Text) * S t r T o F l o a t ( R a t e - > T e x t ) + 0 . 5 ) ,f fFixed, 10, 2 ) ;

    Result , .

    ( ! -) .

    88

  • ?

    (!) ++, ,

    .

    ?, ( , ), -

    - ++? - , ,

    -

    ,

    . ? () . , . -

    , , , .

    ,

    (RoublesNum, RateValue), . , ( ), -

    . ,

    , -

    .

    ! , , -

    .

    ++.

    -

    5-10 , -.

    ,

    .

    , ! , - , , ,

    . -

    ,

    ++. -

    , .

    89

  • 5.

    .

    , , ,

    , ,

    float. -, .

    , -

    .

    ++ - . -

    , , ,

    , -

    .

    , -

    . -

    Roubles Rate StrToFloat(). , , ,

    EConvertError.

    ,

    ( Exception ). - C++Builder 5 .

    90

  • ,

    - , (Help). StrToFloatQ , , EConvertError.

    -

    , -

    . , ,

    .

    -

    . ,

    ,

    , . , RoatToStrF() - ,

    "NAN".

    . -

    , -

    try, :

    t r y{Roubles->Text = FloatToStrF(

    floor(StrToFloat(Dollars->Text) *StrToFloat(Rate->Text) + 0.5), ffFixed, 10, 2 ) ;

    } c a t c h {-), -:

    catch (const - &) :

    catch (const EConvertError &) , -

    ( ) EConvertError. :

    91

  • 5.

    t r y

    Roubles->Text = FloatToStrF(f loor( StrToFloat( Dollars->TextStrToFloat( Rate->Text ) + 0.5 )ffFixed, 10, 2 );

    }catch (const EConvertError &)

    /* */

    ? . ,

    ,

    ,

    , ,

    .

    Windows , ShowMessage() - .

    , , -

    ++ . :

    " ++"

    , :

    "" ( , ) , -

    . ,

    \ ( ):" \" ,

    \". ", C++ ,

    ShowMessageQ:

    92

  • c a t c h ( c o n s t EConver tError &)

    ShowMessage(" " ) ;

    , , -

    C++Builder ( - , ). , ( ) , ,

    . 29.

    CalcpFOject ' ' ,

    ,._-

    . 29. ,

    ? StrToFloat() StrToFloat{ Roubles->Text) - , EConvertError. - StrToFloatO , ( try), , EConvertError ( c a t c h ) . , - try -.

    93

  • 5.

    try , , - catch, . - . ,

    catch-.

    ? -

    , . ++ catch-, .

    catch- ( ), EConvertError , , EOverflow ( - ), - . :

    t r y

    Roubles->Text = FloatToStrF(floor( StrToFloat( Dollars->TextStrToFloatf Rate->Text ) + 0.5 ),ffFixed, 10, 2 ) ;

    catch (const EConvertError &)

    ShowMessage(" ">;

    catch (const EOverflow &

    ShowMessage(" ");

    94

  • 1 el 0 0 0 ( ), 1, , -

    , -

    {). , catch- , , catch-, - try.

    95

  • 6.

    StrToFloat(). . ,

    atoi(), ++ , - . ,

    , -

    , .

    -

    ( string.h), ,

    , -

    ,

    .

    C++Builder AnsiString. ,

    , ,

    , -

    .

    --Builder 3 ,, , ,

    .

    ++ - . :

    (Caption), (Name), (Text)?

    96

  • TButton TEdft, .

    , , ,

    - : , ,

    , .

    , , . ,

    .

    , , . -

    , , -

    .

    ++ . .(), " . " , open - ( ) . ( , ) . . ,

    A. Get Width () , .

    , ++, .

    , , -

    . , .() , , true, , false, .

    ErrorCode = .(); :

    .(); , -

    ( ), - , .

    , , ,

    , , -

    , ? , , - Roubles->Text. ?

    4 3 1064 9 7

  • 6.

    Qcse PageOpen Ftie at CLiratrNJsw Sdtf WindowAdd Tc-Oo item...

    PasteIaggle EookmeiKs

    Oeoug

    Message Viewview EvplDrer

    Sir.VCtri+T

    OtrirV

    *

    S-^CtrKE

    ,

    , -

    ,

    ,

    .. -

    Roubles Calc.h, ,

    Open Source/Header File ( / ) CTRL+F6.

    Calc.h :

    TEdit *Roubles;

    , () Roubles TEdit ( Edit). Roubles TEdit, - *. .

    C++Builder - TEdit (Properties) Text. - :

    p r o p e r t y A n s i S t r i n g Text - {read=GetText,w r i t e - S e t T e x t } ;

    property , Text ( ). - AnsiString. ( , AnsiString ), Methods (), AnsiString. -

    ,

    C++Builder - .

    , -

    ToDouble ( - ... ). , ToDouble,

    98

  • AnsiString () . - StrToFloat() ToDoubleQ:

    RoublesNum = Roubles->Text .ToDouble f ) ; ,

    EConvertError ( ToDoubleO), try- catch-.

    , , -

    CTRL+F4.

    , , -

    , -

    ?

    , -

    . AnsiString c_str(), AnsiString , -

    ,

    .

    atof(). , - C++Builder , s t r i n g (). string tofloating-point conversions ( ) atof{). - ( - ) AnsiString ( c_str()) double. ,

    ( ):RoublesNum = a t o f ( R o u b l e s - > T e x t . c _ s t r ( ) ) ;

    .

    ? atof () - . -

    errno. ,

    99

  • 6.

    ,

    errno.h, .

    , atof() , - ,

    ERANGE. atof() (-, EZERO), ERANGE, , ERANGE, .

    ++. , -

    , -

    C++BuiLder.

    , atof () , - ERANGE. , , ( Roubles) - , .

    ++, ( ?), - , -

    .

    ++

    -

    -

    .

    100

  • 7.

    . , ,

    C++Builder , . -

    -

    , , -2, , -

    , . ,

    , ,

    ,

    . , -

    ,

    .

    , -

    -

    . , Microsoft InternetExplorer 4.x : Web- 255 ( ++ unsigned char 0 255; , , ), Windows - , ( ) .

    (, , ). - ,

    101

  • 7.

    .

    . -

    ,

    . , ,

    .

    . -

    .

    , .

    ( ), - .

    ,

    .

    ++ -. ++ ( -), . :

    if ( ) - ; if . , - , ,

    , -

    .

    (- , true), ( , false). true 1, . - false 0, . ++ boot, , - true false ( ).

    02

  • , ?

    :

    i f ( ){-1 ;-2 ;

    // . .}

    , -

    .

    , - , . -

    , , -

    .

    -

    ( ) .

    = =

    !=

    >

    =

    < =

    , -

    ( , ).

    103

  • 7.

    :

    > 5RateValue , >=, 0) true; (RateValue

  • ( , ++)?

    *3 < +50 > z/3 , ,

    +50, *3, +50, z/. . , ( ) , -

    . C++ , .

    / ++, -^ ,

    . ( ) - .

    , 10, 0, - z 120, :

    10*3 < 0+50 > 120/3

    30 < 50 > 40 (30 < 50) , true. -

    t r u e > 40 ++ : , t r u e 1,

    t r u e > 40

    1 > 40 f a l s e ( 0).

    true false - 1 0! , .

    105

  • 7.

    , *3 < +50 > z/ , Sugest parenthesesto clarify precedence ( , ). , , :

    ( * 3 < + 5 0 ) ScEc ( + 5 0 > z / 3 )

    RateValue DollarsNum RoublesNum .

    :

    RateValue > 0 && RateValue = 0&& RoublesNum < 100000

    RateValue 30, RoublesNum -100, - :

    30 > 0 && 30 = 0 && -100 < 100000

    t r u e && t r u e && f a l s e && t r u e, , -

    ( t r u e && t r u e ) && f a l s e && t r u e( t r u e && f a l s e ) && t r u ef a l s e && t r u e

    f a l s e .

    && || ,

    , .

    false, , false && false false false && true false!

    C++Builder . - , .

    .

    106

  • :

    Ra-eValue > 0 && RateValue 0 &&RateValue - 0 &&RoublesNum < 100000 )

    ( ), - Result Dollars :

    R e s u l t - f l o o r ( RoublesNum / RateValue + 0 . 5 ) ;D o l l a r s - > T e x t = F l o a t T o S t r F ( R e s u l t , f fFixed, 10, 2 ) ;

    107

  • 7.

    :

    i f f RateValue > 0 &&RateValue = 0 &&RoublesNum < 100000 ){R e s u l t = f l o o r { R o u b l e s N u m / R a t e V a l u e + 0 . 5 ) ;D o l l a r s - > T e x t = F l o a t T o S t r F ( R e s u l t , f f F i x e d , 1 0 , 2 ) ;}

    ,

    (, 2 00) . .

    , --

    , -

    . ,

    ?

    , -

    . -

    .

    .

    ,

    , ,

    == . :

    f l o a t , , z,-z = 0; = 3.1415927; - 3.1415927;i f ( == ) 2 = 10;

    , 10, 3.1415926, 3.1415929.

    108

  • , ,

    .

    , ,

    ( ). - , ( , ; -2 +2, -0,001 +0,001, +3,14 +3,14). 4-5 - 1 , -1 .

    ++ abs(). ,

    , :

    i f ' abs( x-y ) < 0 .0001 ) z - 10; z , 10, 0,0001. - . C++, - .

    109

  • 8. .

    ?- . -

    ,

    . ++. ,

    , -

    . .-. ,

    .

    1. ( , ).

    2. 0 .

    3. .

    4. ( ).5. 2 , , -

    . ,

    . ,

    . -

    , .

    6. 1, , .

    7. , 100 .

    , ++ -. ,

    , .

    110

  • , ,

    .

    - .

    CalcProject ( C++Builder) File Close All ( ). , - , C++Builder , (. . 30). (Yes),

    Save cheages to- protea CalcProject?1

    . 30.

    .

    , File New Application ( ). , , C++Builder. , -

    Save All ( ). - ,

    .

    ++ DiceUnit.cpp, - DiceProject.bpr.

    ! .

    ,

    .

    , -

    ,

    , -

    -

    .

    111

  • 8. .

    , -

    ,

    ! , - ,

    -

    , , , -

    , .

    -

    -

    ( , ). .

    1. ( ) ( ).

    2. , .

    3. , -: ,

    , -

    .

    4. , - .

    , , . 31.

    X/ 1

    LasfDiceLastHumanScoia -

    LestComputer Score ComputeiScore : .GameFintsh

    . 31.

    2

  • Name, : HumanScore ( ); ComputerScore ( ); Last HumanScore ( ); LastComputerScore ( ); LastDice ( ).

    ListBox () TotalScores ( ).

    . -

    MainMenu .

    ?

    .

    C++Builder . , , , -

    ,

    . .

    ,

    .

    .

    .

    1. ENTER ,

    Caption.

    2. ENTER C++Builder . (.. 32).

    3. ENTER . ENTER (. . 33).

    4. , ENTER , - 2 3, - (. . 34).

    r^opwtw | Everts j:

    '. AutoHotkeyi

    I BtroapBteax

    f Captitm^Checked

    !

    ! .Hint

    'All shown

    meParent

    rraNane

    w

    jfUB 1

    0

    113

  • 8. .

    ( oiml->MamMenul'. j

    . 32.

    Foim1->MamMenu1]

    . 33.

    . 34.

    , -

    -

    Caption.

    114

  • , ,

    INSERT. -, - ,

    , INSERT Caption ( ). ,

    ?

    -

    &. , , :

    & ,

    , ,

    .

    , .

    , .

    , , , Windows ,

    .

    -

    .

    .

    1. Win32.

    2. ToolBar ( ).

    3. (. . 35).

    4. , -. Additional, SpeedButton ( ToolBar).

    .

    , -

    , C++Builder.

    115

  • 8. .

    [V;"'* Builder 5 - DicePrShowModal(); InputForm , .

    . ,

    BorderStyle ( ) InputForm bsDialog( ). , ? ShowModal() mrOk mrCancel. - , :

    // i f ( lnputForm->ShowModal() == mrOk )

    Input - (, 50 1000). , ,

    input:// InputForm :i f ( InputForm->ShowModal() == mrOk )

    {int input;//

    input = StrToInt( InputForm->Input->Text );// :if( input >= 50 ScSc input

  • ,

    .

    . -

    ( ),

    . -

    . ,

    , -

    . , ,

    , -

    . , , -

    ,

    .

    -

    ,

    , , .

    GAME_FINISH_SCORE. Game.h , TReferee :

    i n t GAME_FINISH_SCORE; , , ,

    . -

    TReferee :

    GAME_FINISH_SCORE = 100; ,

    i f ( Referee .Human.Scores >= GAME_FINISH_SCORE ) Undefined symbol "GAME__FINISH_SCORE"( GAME_FINISH_SCORE )., GAME_FINISH_SCORE ( ) -,

    Referee:

    Referee.GAME FINISH SCORE

    157

  • 9.

    i f f Referee.Human.Scores >= Referee.GAME_FINISH__SCORE )

    , InputForm - 100, , . , -

    . ,

    ( GameFinish), Showlnfo() :

    GameFinish~>Caption = POROG_STR + I n t T o S t r(Referee.GAME_FINISH_SCORE );

    POROG_STR , , Text.h:c o n s t A n s i S t r i n g POROG_STR = " " ;

    Referee.GAME_FINISH_SCORE Input InputForm, PltemClick() ( ) Text input - , :

    InputForm->Input->Text =IntToStr{Referee.GAME_FINISH_SCORE);

    ,

    Referee.GAME_F!NISH_SCORE. Referee.GameFinish() Referee.GAME_FINISH_SCORE, , -

    , .

    i f ( i n p u t >= 50 && i n p u t

  • .

    .

    .

    ,

    if. , , - , :

    // , if( InputForm->ShowModal() !* mrOk ) return;int input-input = StrToInt( InputForm->Input->Text );if( input >= 50 && input

  • 9.

    1. Project Options ( ).

    2. Application ().3. Load Icon ( ) . . 42.4. Windows

    . , ,

    C++Builder( , ). \lmages \Buttons, \lcons. . factory .

    ProjtJcl Option1.| Lrk I Artvanced Ljnjtei J Diecto'ies/

    Vascninfo j e4ckages j 'stir- ] CORBA jFein Apjrfcaaor [ CcncFer | Adarce Conwiar

    1*. Help file.

    Puc. 42.

    -

    . Title , -

    .

    . , ,

    .

    , , -

    , . , ,

    . , -

    160

  • ,

    . -

    , -

    ( Run-Time Libraries, RTL, ) . , C++Builder.

    RTL , , , -

    . , -

    ,

    ( 36 ). O+Builder ( ) - Debug Release. . .

    1. Project > Options ( ).

    2. Compiler ().3. Full debug ( ) Release () -

    , .

    4. (Release) , - RTL Linker () Use dynamic RTL ( - RTL).

    .

    -

    ,

    .

    Advanced Compiler ( ) - Instruction set ( ). 386,486, Pentium Pentium Pro. ,

    ,

    . -

    . ,

    , .

  • 9.

    5. Project Build ( ).

    -

    , -

    Ctrl+F9 () , ,

    .

    Build () - .

    Release Full debug , (- , . .) .

    RTL 91 , ,

    Windows 9x.

    ++

    , -

    , . . -

    C++Builder, . -

    .

    162

  • 10. ?

    -

    ,

    C++Builder ? , , . , ,

    , , . - -

    , -

    .

    , -

    ( - ), , , , 2,..., -

    , N-, , ,

    iV .

    , ? - , , , -

    , ,

    .

    ++ .

    .

    ,

    .

    163

  • 10.

    . :

    _ [ _ ] ;, , :

    i n t x l , 2, /* ... */ 2 0; :

    i n t [ 2 0 ] ; ,

    20 int. , (), , +-, int.

    ++ , . 0, 1, 19. , - , .

    . -

    ( - )

    ( ) . , , , -

    ( ++) -

    ,

    . -

    , , 1 ( - ), 0. 1 . . ,

    , -

    , -

    .

    , , .

    164

  • , ,

    ++ .

    /^gk , :4 1 [0]

    :

    [9] ():

    [19] :

    1 = 5;

    x[0] = x[i] + x[i+l];( , , ).

    ++ . ,

    , -

    . :

    len = 20;in t x [ l e n ] ; // !

    Constant expression required (- ).

    ,

    , . ++ -

    ,

    ,

    Windows , . ,

    , ,

    .

    165

  • 10.

    ++, , , , . , -

    ,

    :

    TDice d ices[100] ;

    , { ; -) Dice TDice, GetDiceValueO .:

    Dice.GetDiceValuef) , , dices? ,

    :

    d i c e s [ 4 9 ] .GetDiceValueO 49, - ++, , (- ). C++Builder -. ,

    AnsiString () (), , ,

    .

    :

    A n s i S t r i n g s;s - "12345";

    s[0] "1", a s[4] = "5".

    C++BuiLder , , -

    , , [](

    ). s[0] AnsiString, . - .

    166

  • .

    , -

    . , ,

    . , -

    : . -

    .

    ,

    ++? . , ,

    1024 256 . :

    i n t e x c e l [ 2 5 6 ] [ 1 0 2 4 ] ; excel 256 , 1024 - int . (100,100) ( ), :

    e x c e l [100][100] excel :

    i n t e x c e l [ 1 0 2 4 ] [ 2 5 6 ] ; (1024 256 ).

    , .

    , -

    . ,

    , -

    X, Y. (, ) 64 ( X) 128 ( Y) :

    int Map [64] [128];

    X, Y:[-4][+1]

    .

    167

  • 10.

    [][] , -

    ,

    .

    , , .

    ,

    :

    i n t W o r l d [ 2 0 ] [ 3 0 ] [ 1 0 ] ; ++ - . , -

    - ( , , ). , , - -

    .

    -

    .

    i n t x [ 2 0 ] [ 2 ] ; :

    [10] [1], , :

    [ 1 ] [10] , , -

    : , 10. - -

    ( 2*20 -40 , 1*10 = 10- , ). , ( , , ). , . ++ - :

    i n t x[10] ; = [ 5 0 ] ;

    1 6 8

  • ,

    .

    50- , 10 ( , 10*4 int 4 32 ), 50 , , , int.

    , , :

    i n t x[10] ;[50] = ;

    , 50 - (50*4 ) . , . ,

    - , -

    , , , , -

    , Windows.

    ++

    . .

    , C++Builder 5 .

    CodeGuard ( ). , .

    CodeGuard ConfigurationFile Help[Preferences % Offons | Function Options j Ignored Modules j

    is Enacted *J2 : Slacjj^ frequency

    |7 Statisticsp" Resowcal,9*s W fiepeated Eras

    " SendtafiUpulDeDiigStrins Lima Durntefdeiior messages

    Eua Message Bo(7 Enable

    epfion jCodeGuard ErrorMessage _ jCodeJuard detected error(5] in the program A log hie Mill be created

    Read debug inloSourae pMh

    Cancel

    1 6 9

  • 10.

    , (Project Options, CodeGuard) , -, ,

    .

    CodeGuard, Tools CodeGuard Configuration ( > - CodeGuard) - ,

    . , -

    (, Enable () "CodeGuard is Enabled"). Code Guard , , , -

    -

    : [ 5 0 ] = ; .

    , -

    . ,

    i n t x [ 1 0 0 ] ; ++:

    i n t i, sum; // i - sum - 0; // for( i = 0; i < 100; i ++ )

    sum += x [ i ] ; , i 0 99,

    100.

    ,

    1, -

    - .

    ? . --

    , .

    170

  • -, C++Builder, , -

    , ,

    ( ). -,

    -

    , -

    - (shareware) .

    - , ,

    C++Builder ( File Close All), ( File New Application). , ++ MainUnit.cpp, a WellProject (Well - ). .

    1. 52 .2. .

    3. 4 11 .

    4. - .

    5. .6. 60 () .7. () . -

    .

    8. , - .

    9. , , .

    10. , - .

    11. 104 .

    171

  • 10.

    12. ( , , , . .). - , .

    .

    13. ( , , . .).

    14. , 5 . - , .

    15. 5 - .

    16. , , ,

    4 , .

    17. 3, 2 .

    18. , , .

    , . -

    36 , .

    ?

    , , -

    52 , - .

    Microsoft, - cards.dll. \Windows\System. cards.dll , , . ,

    Windows. - ,

    . , -

    . , -

    cards.dll.

    72

  • , - -

    . -

    Workshop, C++Builder. ( setup.exe \Workshop\disk1) ( Resource Workshop), File Open Project ( ), FileType ( ) DLL, VBX, CPL Library, cards.dll .

    BITMAP ( ) cards.dll . 1 52 , 53 58 - , 678 684 - .

    -

    (. . 43).Resource Workshop - cards,dlt

    fcNp

    i dReady

    . 43. DLL

    . -

    .

    1. .2. .3. Save resource as (

    ).4. .bmp.

    ,

    , 58,

    173

  • 10.

    53.bmp, ( 54.bmp).

    53

    , -

    , Windows, - Microsoft ( Windows). , ,

    cards.dll - . - -

    .

    , -

    ,

    .

    , -

    , cards.dll .

    , -

    Windows DLL-. , , , cards.dll . , -

    C++Builder.

    - . cards.dll .

    . ,

    -

    .

    Color () Formi clGreen.

    Form 1 ( Caption). ,

    .

    , WindowState ( ) wsMaximized.

    Piepeies [Event

    BorierVaJfr . ;

    CtenfHeTghf

    ,233 - J1 Coi - BlackWarcon

    A oil Navy

    I Purple Teal

    I ^...jy^Gray

  • ""

    cards.dll 71x96 . ,

    800x600 . - ,

    .

    MainMenu ,

    ,

    .

    , -

    ImageList ( -) Win32. , -

    .

    ImageList . -

    , -

    , ,

    , .

    ImageList - .

    1. ImageList .

    2. ( ) 54 (52 , ).

    3. BkColor clWhite ( ).

    4. DrawingStyle ( ) dsNormal ().5. Height ( ) 96 ( -

    cards.dll).6. imageType ( ) itlmage ().7. Masked (

    , ) false ().

    j Litt ''I'-ags-SFropertw j T

    ; AtocBv

    ' Merited""| NameShtralrr-a^e*Width

    |All shown

    zienS*|QetWhta

    ,fsse,IL

    1 7 5

  • 10.

    8. Name ( ) IList ( ).

    9. Width ( ) 71 ( - cards.dll, ).

    10. ImageList. (. . 44).

    h-oim1->IList Imagei ist- Selected

    J:i? O.h

    Puc. 44.

    Add () ( cards.dll .bmp) - . Images - (. . 45).

    Forml->IList ImageListe^lected Irna

    V

    mage's -

    D

    ! j d-

    j gear

    -aw

    r

    i

    - t-i

    . 45.

    ,

    I.bmp, 2.bmp, 52- 52.bmp.

    176

  • , .

    ,

    0 ( ), -

    Selected Image ( ).

    ,

    . -

    , , -

    .

    Transparent Color ( ) cINone ( ), Fill Color ( ) cINone, - Options () Crop (- , ). ,

    .

    , .

    , , -

    .

    _, -

    , ( TCard). - , ,

    , .

    ( ) (, 52), , , ,

    ( ), , .

    ,

    .

    177

  • 10.

    -

    . -

    , ( Project > Add To Project). ( ) File New ( >) Unit (). - CardUnit.cpp.

    CardUnit.h . :

    class TCard

    {private:int Suit; // int Value; // 0- , 1- 2 , 2- 3, ..., 10- ,11- , 12-

    public:void Init(int suit, int value);int GetSuit();int GetValue();

    bool is;};

    Suit (, : 0 , 1 , 2 , 3 ). Value - (0 , 1 ,..., 9 ,..., 12 ). .

    52 TCard, , - . Suit Value protected , TCard . -

    GetSuit() GetValuef). - InitQ.

    178

  • Is (public) . -

    . Is true, .

    :

    c l a s s TPack{private:

    TCard Cards[PACKJTOTAL];

    public:TPack();void Shufflef);void AddCard(TCard card);TCard GetCardO ;TCard GetIndexCard{int i ) ;bool isCardO ;

    ,

    PACK_TOTAL ( ). . () , Shutf 1() - , GetCard() , ( Is), GetlndexCardO , IsCardf) , .

    , () ( , ) (), , , -

    , (, 4 , 8 , ), :

    179

  • 10.

    c o n s t SUIT_NUM - 4; // c o n s t VALUE_NUM = 13; // ?

    , .

    c o n s t PACK_LEN = VALUE_NUM*SUIT_NUM;

    ,

    .

    , , ,

    ,

    .

    , . -

    :

    c o n s t PACK__NUM = 2; // c o n s t PACK_TOTAL = PACK_NUM*PACK_LEN; //

    -

    :

    const KING = 12; // const - 0; //

    ,

    .

    CardUnit.h, - TCard.

    CardUnit.cpp.

    -

    InitQ. Is true ().

    void T C a r d : : I n i t ( i n t s u i t , int value){Suit ~ suit;Value = value;

    180

  • Is = true;}

    , Suit Value, - ;

    int TCard::GetSuitf) { return Su i t ; }int TCard::GetValuef) { return Value; }

    ( 0 51, 52 103). , ,

    , ,

    , -

    . ( 0 3), ( 0 12). - 4*13 - 52 , . :

    int s u i t , va lue; :

    for( s u i t = 0; s u i t < SUIT_NUM; s u i t ++ )

    , ,

    suit - :

    for( s u i t = 0; s u i t < SUIT_NUM; s u i t ++ ){

    forf value = 0; value < VALUE__NUM; value ++ )

    // s u i t value

    :

    for( s u i t = 0; s u i t < SUIT_NUM; s u i t + +

    181

  • 10.

    for( value = 0; value < VALUE_NUM; value ++

    // suit value

    .

    , ,

    , .

    , , ,

    (52 ):f o r ( pack_num = 0; pack_num < PACK_NUM; pack_num ++ )

    f o r ( s u i t = 0; s u i t < SUIT_NUM; s u i t ++ )f o r ( v a l u e = 0; v a l u e < VALUE_NUM; v a l u e ++ )

    {// suit // value}

    , - pack_num -.

    , ? - Cards, card_num, , -

    , -

    .

    :

    : : ( ){int card_num, pack_num, suit, value;

    card_num = 0;

    for(pack_num - 0; pack_num < PACK_NUM; pack_num + +)for( suit = 0; suit < SUIT_NUM; suit ++ )

    for( value = 0; value < VALUE_NUM; value ++ )

    182

  • // Cards[card_num].Init(suit, value)

    // card_num ++ ,-

    Cards 104 - .

    , , -

    ,

    , .

    .

    ,

    -

    .

    ,

    .

    ( ) - (104-) . - ,

    . ,

    , 104, , 1000. .

    v o i d T P a c k : : S h u f f l e { ){int n, rnd;TCard card;

    // " "for ! n = 0; n < PACK_TOTAL; n ++ )

    Cards[n].Is = true;

    183

  • 10.

    // PACK_TOTAL f o r ( n = 1; n

  • .

    Cards, , , Is false.

    . -

    , 0. - 1 . . , , Cards, , Is . Is, true ( ), , , GetCard() -.

    , , -

    Is, true, . , GetCard() - . - ,

    .

    , .

    , GetCard() ( ) , , return, - , , . ,

    , , -

    TCard. - Function should return a value ( ), .

    TCard T P a c k : : G e t C a r d f){

    int i ;for( i = 0; i < PACK_TOTAL; i ++ )

    if( Cards[i].Is ){Cards [i] . Is = false,-return Cards[i] ;

    185

  • 10.

    ShowMessage(" ");return Cards[ 0 ] ;}

    ,

    .

    TCard T P a c k : : G e t I n d e x C a r d ( i n t i) { return C a r d s [ i ] ; } i Cards. , Cards, protected, .

    , ,

    Cards Is, false ( ), . Cards -

    (, 0 ). - Cards , , Is - true, ( , ) . Cards , , , .

    vo id TPack::AddCard(TCard card){int i ;for( i = 0; i < PACK_TOTAL; i ++ )

    if( !Cards[i].Is &&Cards[i].GetValue() = = card.GetValue() &&Cards[i].GetSuit() == card.GetSuit() )

    {Cards[i].Is = true;return;

    }ShowMessage("He ");

    186

  • , .

    Cards, , (- Is true), true, . , ,

    false.bool T P a c k : : I s C a r d ( ){int i ;for( i - 0; i < PACK_TOTAL; i ++ )

    iff Cards[ i] .Is ) return true;return false;}

    ,

    CardUnit.cpp CardUnit.h, , .

    .

    ,

    , -

    .

    -

    ;

    .

    , , -

    (, 100 15 ) ( 20), . -

    ( , ). , , , -

    ,

    .

    187

  • 10.

    ,

    . , -

    : , , , -

    . ( Well TCard), , :

    TCard Well [5] ; ? - , -

    . , Well 5:

    T C a r d W e l l [ 5 ] [ 5 ] ;

    ,

    , -

    Well , - - , ,

    .

    ,

    104 (_1_). PACKJTOTAL:

    TCard Well [5] [5] [PACK_TOTAL] ;

    104 , 5*5*104 , 25 . - -

    .

    , ? . 5*5*104 = 2600 . TCard - int 4 , booL (1 ). 200*(2*4 + 1) = 23400 , 23 . 64 - ! , - .

    Well TFrom 1 Formi, MainUnit.h, public-.

    188

  • Well , , Pack:

    TPack Pack;

    TFormi TCard TPack, MainUnit.cpp MainUnit.h CardUnit.h:

    # i n c l u d e " C a r d U n i t . h "t i n c l u d e "MainUnit .h"

    , ,

    ( 14-17) . Cycle:

    i n t Cycle;

    ? - , ,

    , / , , -

    . ,

    - .

    IList( , 0 51) . :

    i n t GetPacklmagelndexf) ; IList ,

    i n t Get lmage lndex( int l i n e , i n t p o s ) ; , pos line ( , : 0 , i ,2 , 3 , 4 ). MainUnit.h :

    c o n s t BACK_NUM = PACK_LEN;c o n s t NONE^NUM = PACK_LEN+1;

    BACK_NUM, 52, , NONE NUM .

    189

  • 10.

    GetPacklmagelndexO , - , , ,

    ( Is true), IList, :

    *13 + , IList

    , ( ) . , NONE_NUM, , .

    i n t TForml : :GetPack lmage lndex()

    int i ;f o r ( 1 = 0 ; i < PACK_TOTAL; i + + )

    i f ( Pack.GetlndexCard(i)-Is )return Pack.GetlndexCard(i).GetSuit*VALUE_NUM +

    Pack.GetlndexCard(i).GetValueO;return NONEJSJUM;

    GetlmagelndexQ . , ,

    Well. , Well[line][pos] . :

    for( i = PACK_TOTAL-1; i >= 0; i ) i 103 ( 104, ), 0 - >>.

    i n t TForml : :GetImageIndex( int l i n e , i n t pos)

    int i ;for( i = PACK_TOTAL-1; i >= 0; i )

    if( Well [line] [pos] [ibis )return Well[line][pos][i].GetSuitf)*VALUE_NUM +

    190

  • Well[line][pos][i].GetValue();return NONE_NIM;

    }

    pos line TCard G e t C a r d f i n t l i n e , i n t p o s , bool v i e w ) ;

    -

    , ( view true). .

    TCard T F o r m l : : G e t C a r d f i n t l i n e , i n t p o s , bool view){int i ;

    for( i = PACK_TOTAL-1; i >= 0; i )i f ( Well[line] [pos] [i] . Is )

    {// :iff Iview ) Well[line] [pos] [i].Is = false;return Well[line][pos][i];

    ShowMessage(" " ) ;return Well[0][0][0];}

    Getlmagelndex() , (_1_ 1) , . , GetCardQ , , .

    :

    void AddCardfint l i n e , i n t pos , bool pack, TCard c a r d ) ; card pos line. pack -, card ( pack false) .

    191

  • 10.

    , () , Is false( ), (-) . Is , , true .

    void TFormi::AddCard(int l i n e , int pos, bool pack,TCard card)

    {if( pack && IPack.lsCardO ) return;int i;

    forf i = 0; i < PACK_TOTAL; i ++ )i f ( ! W e l l [ l i n e ] [ p o s ] [ i ] . I s )

    {i f ( pack ) w e l l t l i n e ] [ p o s ] [ i ] = Pack.GetCard();else Well [line] [pos] [i] = card,-Well[line] [pos] [ i ] . I s - true;return;

    .

    .

    , , TFormi - MainUnit.h:

    void MoveCard(int l i n e l , int pos l , int I i n e 2 , intpos2) ;

    MainUnit.cpp:void TForrnl: :MoveCard(int l i n e l , int pos l , int I ine2 ,

    int pos2){TCard card;card = GetCard(linel, posl, false) ;AddCard(line2, pos2, false, card);

    192

  • . pos1 linei GetCard{) ( view false), card, AddCard() pos2 Iine2 ( false).

    , , MoveCard(), . :

    v o i d NewGame () ; (Pack.Shuffle()), Cycle( ) - 5. Is Well false ( ). .

    4 11 . AddCard(). 0 ( 0 ), (4 , 0 3), true ( ), card,

    .

    ,

    .

    MoveCardO - 0 0-3 0-3 2 ().

    v o i d TForml::NewGame(){int i, j , p;TCard card;card.lnit(0,0);

    Pack.Shuffle();

    Cycle = 5;

    7 . 1064 1 9 3

  • 10.

    // :for( i = 0; i < 5; i ++ )

    for( j = 0; j < 5; j ++ )for( p = 0; p < PACKJTOTAL; p ++ )

    W e l l [ i ] [ j ] [ p ] . i s = fa lse;

    // 4 11 :for{ i = 0; i < 4; i ++ )

    for{ j = 0; j < 11; j ++ )AddCard f 0, i , true, card) ;

    // :MoveCard(0, 0, 2, 0);MoveCard(0, 1, 2, 1);MoveCard(0, 2, 2, 2 ) ;MoveCard(0, 3, 2, 3) ;

    ,

    -

    . ShowAII().vo id ShowAll{);

    IList, . Draw(),

    IList .

    Draw() ( TCanvas).

    , , ,

    . . , ,

    . C++Builder - , -

    , .

    194

  • .

    TCanvas ( ) C++Builder - Canvas.

    Draw() ( ,X , , , , ), , . ,

    .

    IList. Getlmagelndex(). true. , , - ( false, , ). ,

    -

    ,

    , -

    .

    MainUnit.cpp, . -

    , , : X LEFT, - . :

    ( 1). , -- () LEFT32, - 13.

    // c o n s t CARD_WIDTH - 7 1 ;c o n s t CARD_HEIGHT = 96;

    // const LEFT11 = 314;const = 232;const LEFT12 = 402;const TOP12 = 288;

    195

  • 10.

    const LEFT13 = LEFT11;const TOP13 = 334;const LEFT14 = 226;const TOP14 = TOP12;

    // const LEFT21 = LEFT11;const TOP21 = 128;const LEFT22 = 490;const TOP22 = TOP12;const LEFT23 = LEFT11;const TOP23 = 438;const LEFT24 = 138;const T0P24 = TOP12;

    // const LEFT31 = LEFT14;const TOP31 = 184;const LEFT32 = LEFT12;const TOP32 = TOP31;const LEFT33 = LEFT32;const TOP33 = 400;const LEFT34 = LEFT31;const TOP34 = TOP33;

    // const MAIN_LEFT = 24;const MAIN_TOP = 10;

    // const INV_LEFT = MAIN_LEFT;

    const INV_TOP = MAIN_TOP + CARD_HEIGHT + 20;

    196

  • // :const SHIFT5 = CARD_WIDTH + 10;const LEFT41 = MAIN_LEFT + SHIFT5;const TOP41 ~ MAIN_TOP;

    (-, LEFT23 = LEFT11), - .

    20 10 , .

    ,

    800x600 .

    0 0 :IList->Draw(Canvas, LEFTll,TOPll, GetImageIndex(0,0),

    true); :

    vo id TForml::ShowAl1()

    I L i s t - > D r a w ( C a n v a s , L E F T l l , , G e t l m a g e l n d e x ( 0 , 0 ) ,true);

    I L i s t - > D r a w ( C a n v a s , LEFT12,TOP12, G e t l m a g e l n d e x ( 0 , 1 ) ,true);

    IList->Draw(Canvas, LEFT13,TOP13, Getlmagelndex(0,2),true);

    I L i s t - > D r a w ( C a n v a s , L E F T 1 4 , T O P 1 4 , G e t l m a g e l n d e x ( 0 , 3 ) ,true);

    IList->Draw(Canvas, LEFT21,TOP21, Getlmagelndex(2,0),true);

    I L i s t - > D r a w ( C a n v a s , LEFT2 2,TOP2 2, G e t I m a g e l n d e x ( 2 , 1 ) ,true);

    I L i s t - > D r a w { C a n v a s , LEFT2 3,TOP2 3 , G e t I m a g e l n d e x ( 2 , 2 ) ,true);

    IList->Draw(Canvas, LEFT24,TOP24, Getlmagelndex(2,3),true);

    197

  • 10.

    IList->Draw(Canvas, LEFT31,1, GetImagelndex(1,0),true);

    IList->Draw(Canvas, LEFT32 ,TOP32 , Getlmagelndexd, 1) ,true) ,-

    IList->Draw(Canvas, LEFT33,TOP33, Getlmagelndex(1,2),true);

    IList->Draw(Canvas, LEFT34 ,TOP34 , Getlmagelndexd , 3) ,true);

    IList->Draw(Canvas, LEFT41,TOP41, Getlmagelndex(4,0true);

    IList->Draw(Canvas, LEFT41+SHIFT5,TOP41,Getlmagelndex(4,1), true);

    IList->Draw(Canvas, LEFT41+SHIFT5*2,TOP41,Getlmagelndex{4,2), true);

    IList->Draw{Canvas, LEFT41+SHIFT5*3,T0P41,Getlmagelndex(4,3), true);

    IList->Draw(Canvas, LEFT41+SHIFT5*4,TOP41,Getlmagelndex(4,4}, true);

    // i f ( Pack.I sCardO )

    IList->Draw(Canvas, MAIN_LEFT,MAIN_TOP, BACK__NUM,true);

    else IList->Draw(Canvas, MAIN_LEFT,MAIN_TOP,NONE_NUM, true);

    //

    i f ( IsCards(3,0) )IList->Draw(Canvas, INV_LEFT,INV_TOP,

    Getlmagelndex(3,0) , true);

    else IList->Draw(Canvas, INV_LEFT,INV_TOP, NONE_NUM,true);

    198

  • :

    ,

    ;

    ,

    .

    ShowAll(), , - - -

    , ,

    : ,

    , ,

    . . -

    , - . ? !

    -2 , -

    , C++Builder OnPaint(). , , .

    Form 1, Events OnPaint.

    C++Builder FormPaintO, , , -

    . , , FormPaintO ShowAII().

    void fastcall TForml::FormPaint(TObject *Sender}{ShowAllO ;}

    -

    .

    OnPaintf) , .

    , -

    ,

    , Caption.

    199

  • 10.

    ?

    ShowAll() lsCarcls(). , - :

    bool I s C a r d s ( i n t l i n e , i n t pos) ; true, pos line . :

    bool TForml: :IsCards f int l i n e , int pos){int i ;for( i = 0; i < PACK_TOTAL; i ++ )

    iff Well[line] [pos] [i] .Is )return true;

    return false;

    }

    . -

    .

    ?

    Windows-, . , , -

    , . ,

    , ,

    MoveCard{) .

    , ? OnMouseUp. ( OnPaint), C++Builder :

    void fastcall TForml::FormMouseUp(TObject *Sender,TMouseButton Button,

    TShiftState Shift, int X, int Y)

    200

  • ,

    ( , , - !), . .

    TMouseButton Button

    TMouseButton . mbLeft -, , mbRight , mbMiddle . - Button.

    int X, int Y, , , , ,

    .

    .

    FormMouseUpO . , , , -

    .

    TShiftState Shift

    ,

    CTRL, ALT SHIFT. , Shift ssAlt, ssShift ssCtrl.

    ssDouble , - .

    TShiftState Contains(), , ,

    ( TShiftState), . , -,

    CTRL SHIFT, :S h i f t . C o n t a i n s ( s s D o u b l e ) && S h i f t . C o n t a i n s ( s s C t r l ) &&

    S h i f t . C o n t a i n s ( s s S h i f t ) , FormMouseUpO , , . -

    ( - C++Builder OnMouseDown) ( OnMouseUp). -

    201

  • 10.

    , , , Windows -

    FormMouseDown(). FormMouseUpO , .

    FormMouseDown() , , -

    ,

    .

    -

    , ,

    , -

    . TForm! :i n t L i n e , Pos;

    Line , Pos . Line - - 1 , , .

    Line

    Formi:f a s t c a l l TForml::TForml(TComponent* Owner)

    : TForm(Owner){Line = - 1 ;

    } , , ,

    . ,

    Line (-1) ( -

    ) - return .

    ,

    . . , ,

    0 0, , , , , -

    (LEFT11, 11),

    202

  • (LEFT11+CARD_WIDTH,TOP11+CARD_HEIGHT):

    if { X > LEFT11 &'& X < LEFT11+CARD_WIDTH &&Y > ScSc Y < TOP11+CARD_HEIGHT ){ line = 0; pos = 0 ; }

    line top.

    18. - :

    if( X > LEFT12 && X < LEFT12+CARD_WIDTH &&Y > 12 && Y < TOP12+CARD__HEIGHT ){ line = 0; pos = 1 ; }

    . ., , -

    , -

    .

    -

    , .

    , 18 - (18 ), 4 ( ):

    i n t Coords [18] [4] ;

    ? ,++ , , . -

    , ,

    ,

    ( ), :i n t Coords [18] [4]" =

    {LEFT11,,0,0} , // {LEFT12,TOP12,0,1},{LEFT13,TOP13,0,2},{LEFT14,14,

    0 , 3 } ,

    203

  • 10.

    {LEFT21,21,2,0},{LEFT22,22,2,1},{LEFT23,23,2,2},{LEFT24,TOP24,2,3},

    {LEFT31,TOP31,1,0},{LEFT32,TOP32,1,1},{LEFT3 3,,1,2},{LEFT34,TOP3 4 , 1 , 3 } ,

    // {LEFT41,TOP41,4,0},{LEFT41+S