Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Pro Visual C++-CLI And The .NET 2.0 Platform (2006) [eng]

.pdf
Скачиваний:
46
Добавлен:
16.08.2013
Размер:
24.18 Mб
Скачать

848I N D E X

Active Directory, 200 Adapter service, 607 Add method

caution: unique/duplicate keys, 258 Dictionary<K,V> collections, 273 Hashtable collection, 252 ListDictionary collection, 258 NameValueCollection collection, 261 SortedList collection, 252

Add New Item dialog box, 434, 555 Add Table dialog box, 523

Add Web Reference dialog box, 648, 649 add_<delegate-name> method, 185 AddChild method

CodeGroup class, 786 AddPermission method Permission class, 784

AddRange method RadioButton control, 336

AddResources method ResourceWriter class, 757

address of operator (&), 66 AddXyz methods

LinkedList<T>, 270

Administrative Tools Services application, 606 ADO.NET, 515–558

assemblies containing classes, 516

building database with Visual Studio 2005, 517–526

building stored procedures, 525–526 creating database tables, 519–520 creating database views, 522–524 creating new database, 518

creating relationships between tables, 520–522

classes, 197

connected ADO.NET, 527–543

nontransactional database access, 527–539

transactional database access, 539–543 using simple connected ADO.NET, 527

creating table manually in code, 548 disconnected ADO.NET, 544–558

Constraint classes, 548 core classes, 544 DataAdapter classes, 545 DataColumn class, 547 DataRelation class, 548

DataRelationCollection class, 547

DataRow class, 547 DataSet class, 546 DataTable class, 546

DataTableCollection class, 546 Insert/Update/Delete commands, 536–537 introduction, 515

managed providers, 526–527 namespaces, 516

querying database, 532–535

returning single value from query, 538–539

using connected ADO.NET with transactions, 539–543

using try clause for commands, 531 XML and ADO.NET, 601–603

AfterXyz events, TreeView control, 388 alignment

CheckAlign property, 330 ImageAlign property, 324 LineAlignment property, 474 SetIconAlignment method, 426 TextAlign property, 345

Alignment property StringFormat class, 474 TabControl control, 394

AllKeys property NameValueCollection, 262

AllowColumnReorder property ListView control, 379

AllowItemReorder property ToolStrip control, 404

AllowMerge property ToolStrip control, 404

alpha component A property, 480 colors, 480

ampersand (&) character, 346 Anchor property

RichTextBox control, 357 AND (&&) operator, 62 AnnuallyBoldedDates property

MonthCalendar control, 423 Ansi value

CharSet enumeration, 831 ANSI version

adding A to Windows functions, 831 AnsiBStr value

UnmanagedType enumeration, 834 apartment state, 311

APIs (application programming interfaces)

.NET Framework advantages, 6 AppDomain class

SetPrincipalPolicy method, 778, 779 Appearance property

CheckBox control, 330 TabControl control, 394

Append value

FileMode enumeration, 289 AppendChild method

XmlNode class, 584 AppendText method

File/FileInfo classes, 288 TextBoxBase class, 344

Application class, 214 methods/properties, 311

application configuration files, 754, 755 application development

.NET Framework, 21–23

.NET Framework hierarchy, 5 console applications, 21 Web applications, 22

Web services, 22 Windows applications, 21 Windows services, 22

Application Domain statements, 785 ApplicationActivationAttribute, 202 ApplicationDeployment class, 198 ApplicationException, 170

.NET Framework exception types, 168 rethrowing exception, 172

throwing, 170 ApplyResources method

ComponentResourceManager class, 769 Archive attribute, files, 286

ARGB value

FromArgb method, 480 ToArgb method, 480

argument lists CLS and, 20

arguments

passing by reference, 77 passing to functions, 76–77 passing to main function, 80–82

arithmetic operators, 61–62

binary operator overloading, 115 precedence, 62

I N D E X 849

ArrangeIcons method ListView control, 380

arranging

AutoArrange property, 380 Array class

GetLength method, 46 IndexOf method, 372 Length property, 46 Reverse method, 48 Sort method, 48

array properties

member properties, ref class, 123 ArrayList collection, 245–248

accessing, 246 BinarySearch method, 247

caution: accessing nonexistent element, 247 caution: increasing capacity of, 246 Contains method, 247

creating from another collection, 246 default Capacity, 245

default index property index start number, 247 description, 241

List<T> collection and, 265 loading, 246

namespace, 196 Reverse method, 247

setting initial capacity, 246 Sort method, 247

arrays, 46

accessing elements of arrays, 48 ArrayList collection, 245 BitArray collection, 248–251 caution: jagged arrays, 48

CLS and, 20

CompoundArray property, 482, 485 CTS data types, 18

declaring, 47 IsArray property, 732

multidimensional arrays, 47 arrays, .NET

LinkedList<T> compared, 269 ref class benefits, 92

arrow (->) operator

accessing ref class members, 97 accessing reference object handle, 96

ASCII character set, 40

850I N D E X

ASP.NET Web Service template creating Web service, 638 designer code, 640 FindZipCodeClass ref class, 641 FindZipCodeClass.asmx file, 639 FindZipCodeClass.h file, 639

redundant namespace qualifying, 640 WebServiceBinding attribute, 640

assemblies

.NET Framework class library, 194

.NET Framework elements, 7–11 assembly metadata/manifest, 8

assembly referencing, 154–155

building from multifile libraries, 149–154

building library assembly from command line, 154

global assembly cache (GAC), 7 header files, 149

IntelliSense using metadata, 9 Microsoft intermediate language, 10 private assemblies, 7

resources, 11

self description, 8 shared assemblies, 7 structure of, 7 templates and, 156 type metadata, 9 versioning, 9

Assembly class, 207, 730, 735 GetTypes method, 730

assembly programming, 729–772 attributes, 738–745 globalization/localization, 764–772 reflection, 729–738

resources, 755–763

shared assemblies, 746–755 assembly tag

NDoc generated documentation, 221 AssemblyCultureAttribute attribute, 752 assemblyIdentity element, 755 AssemblyKeyFileAttribute attribute, 752 AssemblyName class, 207, 730 AssemblyNameProxy class, 207 AssemblyVersionAttribute attribute, 750 assignment (=) operator, 65–66

binary operator overloading, 115 caution: equal to (= =)operator, 62

asterisk (*) character pointer data type, 30

AsyncCallback class, 721, 724 asynchronous sockets, 720, 721

accepting connections, 721, 722 asynchronous TCP server, 725–727 connecting to connections, 722, 723 disconnecting from connections, 723 receiving message, 724, 725

sending message, 724 AsyncState property

IAsyncResult class, 723, 725 Attribute class, 742

GetCustomAttribute method, 743 GetCustomAttributes method, 743 System namespace, 739

Attribute node type, XML, 564 AttributeCount property

XmlReader class, 562 attributes, 738, 739

common language runtime (CLR), 14 creating custom attribute, 739–742 GetAttribute method, 563, 593 HasAttributes property, 562, 593 implementing custom attribute, 742, 743 MoveToAttribute method, 563, 593 MoveToFirstAttribute method, 563, 593 MoveToNextAttribute method, 563, 594 NewLineOnAttribute property, 574 ReadAttributeValue method, 563

using custom attribute, 743, 745 WriteAttributes method, 575 WriteAttributeString method, 575 WriteEndAttribute method, 575 WriteEndDocument method, 575 WriteStartAttribute method, 575 XML documents, 560

Attributes property FileSystemInfo class, 280 XmlNode class, 583

AttributeTargets enumeration, 739, 740 AttributeUsageAttribute attribute, 739, 740 Authentication namespace, 212, 776 AuthenticationType property

IIdentity interface, 777 Authors table

column descriptions, 519 entering data, 524

auto modifier

data types, C++/CLI, 52 Auto value

CharSet enumeration, 831 AutoArrange property

ListView control, 380 AutoIncrement property

DataColumn class, 547 AutoLog property

ServiceBase class, 614 AutoResetEvent class, 662 AutoScroll property

Form class, 315 AutoScrollMinSize property

Form class, 494 AutoScrollPosition property

Form class

optimizing GDI+, 499 scrollable windows, GDI+, 496

AutoSize mode PictureBox control, 420

AutoToolTip property ToolStrip control, 405

B

B property, Color class, 480 BackColor property, Label control, 324 Background state

multithreaded programming, 665 backslash (\) character, 347

escape sequences, 58 BackwardDiagonal enumeration

HatchStyle enumeration, 486 base classes

.NET Framework hierarchy, 5 parent classes, 93

Base64

WriteBase64 method, 575 BeepOnError property

MaskedTextBox control, 345 BeforeExpand event

TreeView control, 392 BeforeXyz events

TreeView control, 388 BeginAccept method

Socket class, 721, 722

I N D E X 851

BeginAcceptSocket method TcpListener class, 721

BeginAcceptTcpClient method TcpListener class, 721

BeginConnect method Socket class, 722 TcpClient class, 722

BeginDisconnect method Socket class, 723

BeginReceive method Socket class, 724 UdpClient class, 724, 725

BeginReceiveFrom method Socket class, 724

BeginSend method Socket class, 724 UdpClient class, 724

BeginSendTo method Socket class, 724

BeginTransaction method SqlConnection class, 543

binary

overloading binary operators, 114 WriteBinHex method, 575

BinaryFormatter class, 211 serialization using, 304–306 SoapFormatter class compared, 304

BinaryReader class, 203 drawback using, 300 ReadXyz methods, 300 using, 299–302

BinarySearch method ArrayList collection, 247

BinaryWriter class, 203 methods, 300 using, 299–302

Binder class, 207

BindingFlag enumeration, 845 bindingRedirect element, 755 BitArray collection, 248–251

description, 241 namespace, 196 NOT method, 249 SetAll method, 249

Bitmap class

double buffering, 503 namespace, 446

852I N D E X

bitmaps

FromHbitmap method, 490 BitVector32 collection

description, 241 namespace, 196

bitwise operators

AND (&) operator, 63 OR (|) operator, 63 precedence, 64

XOR (^) operator, 63, 64 BlinkRate/BlinkStyle properties ErrorProvider control, 426

blue component B property, 480

Bold property, Font class, 476 BoldedDates property

MonthCalendar control, 423 bool alias, Boolean data type, 38 Bool value

UnmanagedType enumeration, 834 Boolean data type, 38–39

Boolean literals, 57 ToString method, 57

borders

FormBorder property, 315 BorderStyle property

PictureBox control, 420 Bottom property

Rectangle/RectangleF structures, 465 bounds

GetBounds method, 469, 490 boxed value types

CTS data types, 18 boxes

CheckBox control, 214, 330–333 CheckBoxes property, 387 CheckedListBox control, 368–372 CheckListBox class, 214 ComboBox control, 214, 364–368 dialog boxes, 434–444

GroupBox control, 336–340 ListBox control, 359–364 ListBoxItem method, 552 MaskedTextBox control, 345–352 MaximizeBox property, 315 MessageBox function, 826 MinimizeBox property, 315

PictureBox control, 420–422 RichTextBox control, 215, 352–358 TextBox control, 215, 345, 347 TextBoxBase class, 344 ThreeDCheckBoxes property, 368 ToolStripComboBox, 404, 414, 415 ToolStripTextBox, 404, 414

boxing data types, 51–52

caution: modifying boxed object, 52 break statement

looping, C++/CLI, 75 switch statement, 71

brightness

GetBrightness method, 480 Brush class, 446, 486

TranslateTransform method, 487 Brushes class, 446

brushes, GDI+, 486–489 HatchBrush class, 486 SolidBrush class, 486 SolidBrushes class, 447 start point for filling, 487 SystemBrushes, 447, 486

TextureBrush class, 447, 487–489 BStr value

UnmanagedType enumeration, 834 buffering, GDI+

double buffering, 501–508 single buffering, 501

build version, 749 BuildRadios method, 340 built in value types

CTS data types, 19 bulleted lists

integrated XML documentation, 231 SelectionBullet property, 353

BulletIndent property RichTextBox control, 353

Button control, 214, 327–329 InitializeComponent method, 329 static/dynamic control, 327

way too many buttons, 329 button controls, 327–343 Button property

MouseEventArgs class, 319 ButtonBase class, 327

buttons

AcceptButton property, 436 CancelButton property, 436 OverflowButton property, 405 RadioButton control, 215, 334–336 ToolStripButton, 404 ToolStripDropDownButton, 404 ToolStripSplitButton, 404

Byte integer data type, 33

C

C masking character, 346 c tag

example using, 238

integrated XML documentation, 229 C++

unsafe code, 825

accessing COM components from .NET, 837–846

creating, 807

data marshalling, 833–837 including vcclr.h file, 820, 821, 822 introduction, 805, 806

managed/unmanaged #pragma directives, 807, 808, 809

neccessity of, 806, 807 P/Invoke, 825–833 pointers, 815–820 unmanaged arrays, 810

unmanaged classes/struts, 811–815 unsafe programming, 805

C++/CLI comments, 60–61

CRT/managed heaps, 92 flow control constructs, 69–71 functions, 76–82

Hello World program, 27–28 literals, 55–60

looping constructs, 71–75 object-oriented programming, 89–137 operators, 61–69

programming basics, 27–83 statements, 29

support for Web services, 638 variables/data types, 29–55

Cache namespace, 206 Caching namespace, 213 Calendar class, 202, 765

I N D E X 853

CalendarDimensions property MonthCalendar control, 423

calendars

MonthCalendar control, 423–425 CallingConvention enumeration, 829

values, 831 CallingConvention field

DllImportAttribute class, 831 Cancel property

CancelEventArgs argument, 352 Cancel type DialogResult, 435 CancelButton property

dialog boxes, 436 CancelEventArgs argument

Cancel property, 352 CanHandlePowerEvent property

ServiceBase class, 614 CanHandleSessionChangeEvent property

ServiceBase class, 614 CanOverflow property

ToolStrip control, 404 CanPauseAndContinue property

ServiceBase class, 614 ServiceController class, 628

CanRead property Stream class, 292

CanRedo property RichTextBox control, 353

CanSeek property Stream class, 292

CanShutDown property ServiceBase class, 614 ServiceController class, 628

CanStop property ServiceBase class, 614 ServiceController class, 628

CanUndo property TextBoxBase class, 344

CanWrite property Stream class, 292

Capacity property

ArrayList collection, 245, 246

caution: setting less than Count, 246 Hashtable collection, 252 MemoryStream class, 295

SortedList collection, 252

854I N D E X

carat (^) character handle data type, 30

case

CharacterCasing property, 345 case sensitivity

CLS and, 20, 193 case statement, 70–71 casting

explicit cast, 53 safe_cast, 54

type conversions, 53–54 catch blocks

catching multiple exceptions, 173

catching previously uncaught exceptions, 176 exception handling described, 167

order of system exception inheritance, 174 rethrowing exception, 172

unsafe code, 176 CDATA section

CreateCDataSection method, 584 XmlCDataSection class, 582

Cdecl value

CallingConvention enumeration, 831 Ceiling method

Point/PointF structures, 463 Rectangle/RectangleF structures, 465 Size/SizeF structures, 464

CenterImage mode PictureBox control, 420

chaining

multicast chaining, 179 ChangeExtension method

Path class, 282 Channels namespace, 210

Char (16-bit) data type, 39, 58 char (8-bit) data type, 34, 58 char alias, integer data type, 33 char entity

WriteCharEntity method, 575 character data type, 39–40 character literals

Char (16-bit) types, 58 char (8-bit) types, 58 escape sequences, 58 literals, C++/CLI, 58–59

CharacterCasing property TextBox control, 345

characters

IndentChars property, 574 PasswordChar property, 345 PtrToStringChars function, 822 WriteChars method, 575 XmlCharacterData class, 582

CharSet enumeration ExactSpelling value, 831 namespace, 829 values, 831

CharSet field DllImportAttribute class, 831

CheckAlign property CheckBox control, 330

CheckBox control, 214, 330–333 properties, 330 uncheckable control, 333

CheckBoxes property TreeView control, 387

Checked property CheckBox control, 330

ToolStripMenuItem control, 415 TreeNode class, 389

CheckedChanged event RadioButton control, 336

CheckedIndices property CheckedListBox control, 368, 369

CheckedItems property CheckedListBox control, 368, 369

CheckedListBox control, 368–372 checking box within control, 372 events, 372

getting checked items, 369 methods, 368

properties, 368

selected vs. checked items, 368, 369 splitting CheckedListBox, 369

CheckListBox class, 214 CheckOnClick property

CheckedListBox control, 368 ToolStripMenuItem control, 415

CheckState property CheckBox control, 330

ToolStripMenuItem control, 415 child classes

ref class inheritance, 93

ChildNodes property XmlNode class, 583

children

AddChild method, 786 AppendChild method, 584 FirstChild property, 583, 586 HasChildNodes property, 583 LastChild property, 583 PrependChild method, 584 RemoveChild method, 584, 786, 789 ReplaceChild method, 584 SelectChildren method, 594

Children property CodeGroup class, 786

Clamp enumeration WrapModes enumeration, 487

clamping, 487 class library

see also NET (.NET) Framework class library

.NET Framework, 23–24, 193–216 accessing resources, 11

class templates, 158–159

caution: definition/implementation of, 159 template parameters, 160–162

class types

CLS and, 20, 193

type casting between, 131 classes, 50

see also unmanaged classes/struts

.NET generic collection classes, 242

.NET standard collection classes, 241 creating event source class, 184 declaring ref classes, 89

default to CRT heaps, 92 defining before using, 441 nested ref classes, 128

ref keyword, 92

setting up classes for serialization, 302–304 ClassInterfaceAttribute class, 208

Clear method Graphics class, 454

Hashtable collection, 252 Queue collection, 256 SortedList collection, 252 Stack collection, 256 TextBoxBase class, 344

I N D E X 855

ClearSelected method ListBox control, 359

ClearUndo method TextBoxBase class, 344

clicking

CheckOnClick property, 368, 415 Clicks property

MouseEventArgs class, 319 ClientSize property

Form class, 315 Clipboard class, 214 CloneNode method

XmlNode class, 584 Close method

BinaryWriter class, 300 Connection classes, 531 ResourceReader class, 762 ResourceWriter class, 757 ServiceController class, 628 Socket class, 704

Stream class, 292, 293 StreamReader class, 297 StreamWriter class, 298 XmlReader class, 563

placing in finally clause, 567 XmlWriter class, 575

CLR (common language runtime)

.NET Framework elements, 11–17

.NET Framework hierarchy, 5 attributes, 14

CLR start-up process flow, 12 code access verification, 14 code verification, 14

command-line switches (/CLR:), 13 garbage collection, 14 instantiating ref class objects, 96 JIT (just-in-time) compilation, 17 language support for CTS types, 19 managed code, 13

managed data, 13

multiple language support, 15 multiple platform support, 16 reflection, 15

roles of, 11 services, 13

versioning in private assemblies, 749

856I N D E X

CLS (common language specification), 20 coclass, COM, 842

code

managed code, 13 native code, 13 safe/unsafe code, 13

code access security, 211, 783

code groups, 785, 786, 787, 788, 789 evidence, 790–795

permissions, 783, 784 policy statements, 784, 785 securing code, 795

Assert/RevertAssert, 799, 800 Demand, 796

Demands, 796 Deny/RevertDeny, 800 InheritanceDemand, 797 LinkDemand, 797 Overrides, 799

PermitOnly/RevertPermitOnly, 800, 802 RequestMinimum, 798 RequestOptional, 798

RequestRefuse, 798 Requests, 798

code access verification common language runtime, 14

code groups

code access security, 785, 786, 787, 788, 789 code tag

example using, 238

integrated XML documentation, 230 code verification

common language runtime, 14 Codebehind attribute

C++/CLI support for Web services, 638 CodeGroup class

adding readonly CodeGroup, 787 properties/methods, 786 RemoveChild method, 789

coding membership conditions, 786 collection classes, 546 Collection<T> class, 197, 242, 278 CollectionBase collection, 241

Collections namespace, 23, 195, 196, 197, 257, 264

Collections::Generic namespace, 23, 264 Collections::Specialized namespace, 257

collections, .NET collection classes

ArrayList, 241, 245–248

BitArray, 241, 248–251 BitVector32, 241 CollectionBase, 241 Collection<T>, 242, 278

DataRelationCollection, 198, 544, 547 DataTableCollection, 546 DictionaryBase, 241 Dictionary<K,V>, 242, 273–277 Hashtable, 241, 251–255 HybridDictionary, 241, 258 ICollection interface, 243 KeyCollection, 274 KeyedCollection<K,V>, 242, 278 LinkedList<T>, 242, 269–271 ListDictionary, 242, 257–259 List<T>, 242, 265–268 NameValueCollection, 242, 261–263 PropertyDataCollection, 205 QualifierDataCollection, 205

Queue, 242, 255–257 Queue<T>, 242, 271–272

ReadOnlyCollection<T>, 242, 278 SortedDictionary<K,V>, 242, 273–277 SortedList, 242, 251–255

Stack, 242, 255–257 Stack<T>, 242, 271–272 StringCollection, 242, 259–260

StringDictionary, 242, 260–261 ValueCollection, 274

generic collection classes, 242 properties/methods not supported, 264 thread safety, 264

generic collection interfaces, 243 main sets of .NET collections, 241 namespaces and inheritance, 241 other sets of collections, 241

ref class benefits, 92

standard collection classes, 241 standard collection interfaces, 243

colon (:) character, 347 Color class

constructor, 480

creating named colors, 481 FromXyz methods, 480 methods, 480

placing color information into Color structure, 480

predefined colors, 481 properties, 480

Color property, Pen class, 482 Color structure

creating array of static color properties, 736 Drawing namespace, 446

ColorDepth property ImageList component, 378

ColorDialog dialog box, 442 calling, 442

colors

alpha component, 480 BackColor property, 324 building custom colors, 481 ForeColor property, 324

FromKnownColor method, 480, 481 GDI+, 480–481

IsKnownColor method, 480 IsNamedColor method, 480 IsSystemColor method, 480 predefined colors, 481 SelectionColor property, 353 SystemColors class, 447 ToKnownColor method, 480 TransparentColor property, 378

columns

AllowColumnReorder property, 379 DataColumn class, 547 MultiColumn property, 359

Columns property DataTable class, 546 ListView control, 380

COM coclass

invoking Interop Assembly, 842 COM components, accessing from .NET

Interop Assembly, 839 creating, 839–841 introduction, 837, 839

COM interoperability Runtime::InteropServices namespace, 208

COM objects errors, 843, 844

late binding, 844, 845

Combine method, delegates, 181, 185 combo boxes

ToolStripComboBox, 404, 414

I N D E X 857

ComboBox control, 214, 364–368 current value, 368 DropDownStyles, 364 methods, 365

properties, 364

synchronizing style controls, 365 ComboBoxStyle list

ComboBox control, 364 ComDefaultInterfaceAttribute class, 208 COM/COM+

.NET Framework advantages, 6 comma (,) character, 346

comma operator, 65 Command classes

Insert/Update/Delete commands, 536–537 querying database, 532–535

returning single value from query, 538–539 Command properties

DataAdaptor class, 545 command-line switches

managed code, C++/CLI, 13 COMMANDLINE_DEBUG symbol

debugging Windows services, 632 CommandText property

SqlCommand class, 532, 534 CommandType property

SqlCommand class, 532, 534 Comment node type, XML, 564 comments, 60–61

see also documentation embedded comment problem, 61 IgnoreComments property, 571 multiline comments, 60 single-line comments, 60

triple slash comments

see triple slash (///) comments WriteComment method, 575 XML documents, 560

Commit method SqlTransaction class, 543

common language runtime see CLR

common language specification (CLS), 20 Common namespace, 516

common type system see CTS

communication protocols Web services, 636–637