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

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

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

868I N D E X

Exclusive attribute PolicyStatementAttribute class, 785

ExecuteCommand method ServiceController class, 628, 629, 630

ExecuteNonQuery method SqlCommand class, 529

Insert/Update/Delete commands, 536–537 ExecuteReader method

SqlCommand class, 529 querying database, 532–535

ExecuteScalar method SqlCommand class, 529

returning single value from query, 538–539 Execution permission, 784

Exists method, List<T> collection using Predicate<T>, 266

Exists property FileSystemInfo class, 280

Exit method, Monitor class, 685 exitContext parameter

WaitOne method, Mutex class, 689 explicit (named) virtual overriding, 107 explicit cast, 53

exponential numbers, 56 Extension property

FileSystemInfo class, 280 extern modifier

data types, C++/CLI, 52

F

FastCall value

CallingConvention enumeration, 831 FieldInfo class, 207, 730

File class, 203

file access classes, 279 managing file system, 285 methods, 286

methods for opening files, 288 Open method, 289–290 opening files using, 288

file system input/output, 279–302 managing, 280–288

Directory/DirectoryInfo classes, 280 File/FileInfo classes, 285 FileSystemInfo class, 280

FileAccess enumeration, 289 FileInfo class, 203

file access classes, 279 managing file system, 285 methods, 286

methods for opening files, 288 Open method, 289–290 opening files using, 288 using, 286

FileIOPermission class, 783, 784 FileMode enumeration, 289 FileNotFoundException class, 203, 750 files

common activities with, 286 common attributes, 286 file system I/O, 279 FromFile method, 490 GetFileName method, 282 GetFiles method, 281

I/O manipulation, 291–302 listing files/directories, 281 LoadFile method, 352, 353 opening, 288–290

standard open configurations, 290 SaveFile method, 354

FileShare enumeration, 290 FileStream class, 203, 292–294

opening FileStream, 292 reading/writing to streams, 292

FileSystemDriver service, 607 FileSystemInfo class

managing file system, 280 properties/methods, 280 FileSystemWatcher class, 203

Fill method

DataAdaptor classes, 546 FillClosedCurve method, 454 FillEllipse method, 454 filling

brush start point for, 487 optimizing GDI+, 498

FillPie method, 454 FillPolygon method, 454 FillRectangle(s) methods, 454 FillRegion method, 471

Finalize destructor method, 105

finally block

ADO.NET exceptions, 531 exception handling described, 167

executing code regardless of exceptions, 177, 178

placing Close method in, 567 Find method

LinkedList<T>, 270 List<T> collection, 266 RichTextBox control, 353

FindAll method, List<T> collection using Predicate<T>, 266, 267

FindIndex method, List<T> collection using Predicate<T>, 267

FindLastIndex method, List<T> collection using Predicate<T>, 267

FindList method LinkedList<T>, 270

FindList method, List<T> collection using Predicate<T>, 267

FindString method ListBox control, 359

FindStringExact method ListBox control, 359

FindZipCode web page, 642 FindZipCode Web service

accessing using getzip.html, 647 accessing using HTTP POST, 646 accessing using SOAP, 647–650 HTTP POST request, 645

HTTP POST response, 645 remote copy available at, 648 Request SOAP wrapper, 644 Response SOAP wrapper, 645 WSDL, 642

FindZipCodeClass ref class

ASP.NET Web Service template, 641 GetZip method, 641

FindZipCodeClass.asmx file

creating ASP.NET Web service, 639 FindZipCodeClass.cpp

creating Web service, 641 FindZipCodeClass.h file

creating ASP.NET Web service, 639 FirstChild property

XmlDocument class, 586 XmlNode class, 583

I N D E X 869

first-in-first-out (FIFO) collection see Queue collection

FirstNode property TreeNode class, 389

FixedPanel property SplitContainer control, 398

flags

FormatFlags property, 474 FlatStyle property

ButtonBase class, 327 flickering

double buffering, 501 flips

RotateFlip method, 490

float alias, floating-point data types, 35 floating point data types, C++/CLI, 35–36 flow control, C++/CLI, 69–71

if statement, 69–70 switch statement, 70–71

Flush method

Stream class, 292, 293 StreamWriter class, 298 XmlWriter class, 575

FocusItem property ListView control, 380

FolderBrowserDialog dialog box, 442 Font class, 446, 476

Font property

Label control, 324 FontDialog dialog box, 442 FontFamily class, 446, 476 FontFamily property

Font class, 476 fonts

building font, 476 GDI+, 476, 479

generating random fonts, 477 InstalledFontCollection class, 479 SelectionFont property, 353 SystemFonts class, 447

using less common fonts, 476 for each loop, 74–75

continue statement, 75

iterating through collections, 244 for loop, 73–74

continue statement, 75 ForEach method

List<T> collection, 266

870I N D E X

ForeColor property Label control, 324

Foreign Key Relationships property page, 521 ForeignKeyConstraint

Constraint classes, ADO.NET, 548 Form class, 215, 314–316

adding member variables, 326 AutoScrollMinSize property, 494 AutoScrollPosition property, 496 Control class relationship, 449 customizing, 316–318 InitializeComponent method, 315 Language property, 769 properties, 315

TabPage compared, 395 form validation

ErrorProvider control, 426 FormatFlags property

StringFormat class, 474 Formatter class, 211 FormatterServices class, 211 formatting

BinaryFormatter class, 211, 304 SoapFormatter class, 211, 304 StringFormat class, 447, 473, 474

formatting tags

integrated XML documentation, 229–233 FormBorder property

Form class, 315

Forms namespace, 24, 214 forward only access, XML, 561–580 forward slash (/) character, 347 friends

ref class drawbacks, 93 FromArgb method

Color class, 480, 481 FromFile method

Image class, 490 FromHbitmap method Image class, 490

FromKnownColor method Color class, 480, 481

FromName method Color class, 480 FromStream method Image class, 490 FullName property

FileSystemInfo class, 280

FullPath property TreeNode class, 389

FullRowSelect property ListView control, 380

FullTrust permission, 784 function templates, 156–158 functional notation

declaring variables, 30 functionality tags

integrated XML documentation, 223–228 FunctionPtr value

UnmanagedType enumeration, 834 functions, C++/CLI, 76–82

description, 28 naming restrictions, 76 overloading, 80 parameters, 76

passing arguments, 76–77

passing arguments by reference, 77 passing by reference, 76

passing handle by value, 76 to main function, 80–82

prototypes, 79 return statement, 77 return type, 76

returning values from, 77–79 returning handles, 78 returning references, 78 fundamental data types, 32, 33–40

G

G property, Color class, 480

GAC (global assembly cache), 746, 747 adding assemblies to, 747, 748 assembly structure, 7

assembly versioning, 9

shared assemblies strong name, 748 garbage collection

.NET Framework advantages, 6 common language runtime (CLR), 14

deterministic cleanup Graphics objects, 455 GC class, 195

multithreading, 212 ref class benefits, 92 ref keyword, 14

GC class, 195 GCHandle class, 821

gcnew operator

cleaning up unmanaged resoutces, 105 instantiating ref class objects, 96

ref class constructors, 101 ref class drawbacks, 93 reference data types, 46

gcroot<T> template, 821

GDI (Graphical Device Interface), 200 GDI+, 200, 445–513

brushes, 486–489 colors, 480–481

coordinate systems, 459–462 double buffering, 501–508

drawing custom shapes/lines, 492–494 drawing strings, 472–475

Font class, 476 FontFamily class, 476 fonts, 476–479 Graphics class, 454–459

Hello World program, 447–449 Invalidate method, 459 namespaces, 446–447

OnPaint method vs. PaintEventHandler, 450–453

optimizing, 498–501 pens, 481–485 printing, 508–512

referencing assembly (#using), 447 rendering existing images, 489–492 scrollable windows, 494–497

GDI+ classes Bitmap class, 503 Brush class, 486 Color class, 480 Font class, 476

FontFamily class, 476 Graphics class, 449, 454–459 HatchBrush class, 486 Image class, 490

Pen class, 481 PrintDocument class, 509 Region class, 462, 469–471 SolidBrush class, 486 StringFormat class, 474 System::Drawing classes, 446 TextureBrush class, 487

I N D E X 871

GDI+ structures

common utility structures, 462–471 int/float versions, 463 Point/PointF, 462, 463–464 Rectangle/RectangleF, 462, 465–468 Size/SizeF, 462, 464–465 System::Drawing structures, 446

Generate XML Documentation Files property integrated XML documentation, 220

generic class, 195

generic collection classes, .NET, 242, 264 generic collection interfaces, .NET, 243 Generic namespace, 23, 195, 196, 197, 264 GenericDefault property

StringFormat class, 474 GenericIdentity object, 776, 779 GenericPrincipal object, 777, 778, 779, 780 generics, 163–165

templates compared, 163, 164 GenericTypographic property

StringFormat class, 474 Get method

array properties, ref class, 123 indexed properties, ref class, 124 member properties, ref class, 118 NameValueCollection collection, 262 scalar properties, ref class, 119

static properties, ref class, 121 GetAttribute method

XmlReader class, 563 XPathNavigator class, 593

GetAttributes method, File class, 285 GetBits method

Decimal data type, 37 GetBounds method

Image class, 490 Region class, 469 GetBrightness method Color class, 480

GetBuffer method MemoryStream class, 295

GetByIndex method

SortedList collection, 251, 253 GetConstructor(s) methods

Type class, 732

872 I N D E X

GetCreationTime method

GetInterface method, Type class, 732

Directory class, 281

GetItemAt method

File class, 285

ListView control, 380

GetCurrentDirectory method

GetItemChecked method

Directory class, 281

CheckedListBox control, 368, 369

GetCustomAttribute(s) methods

GetItemCheckState method

Attribute class, 743

CheckedListBox control, 368, 369

GetDirectories method

GetKey method

Directory/DirectoryInfo classes, 281

NameValueCollection collection, 262

GetDirectoryName method

GetLastAccessTime method

Path class, 282

Directory class, 281

GetElementById method

File class, 285

XmlDataDocument class, 601

GetLastWinError method

XmlDocument class, 585

Marshal class, 832

GetElementFromRow method

GetLastWriteTime method

XmlDataDocument class, 601

Directory class, 281

GetElementsByTagName method

File class, 285

XmlDocument class, 585

GetLength method, Array class, 46

GetEnumerator method

GetLogicalDrives method

Hashtable collection, 252

Directory class, 281

IEnumerable interface, 243

GetMember(s) methods

ResourceReader class, 762

Type class, 732

SortedList collection, 252

GetMethod(s) methods

GetEvent(s) methods

Type class, 732

Type class, 732

GetObject method

GetExtension method

ResourceManager class, 763

Path class, 282

GetProperties method

GetField(s) methods

Type class, 732

Type class, 732

GetProperty method

GetFileName method

Type class, 732

Path class, 282

GetRowFromElement method

GetFileNameWithoutExtension method

XmlDataDocument class, 601

Path class, 282

GetSaturation method

GetFiles method

Color class, 480

Directory/DirectoryInfo classes, 281

GetSelected method

GetFileSystemEntries method

ListBox control, 360

Directory class, 281

GetServices method

GetFileSystemInfos method

ServiceController class, 628

DirectoryInfo class, 281

GetSocketOption method

GetFullPath method, Path class, 282

Socket class, 719, 720

GetHashCode method

GetStream method

Object data type, 41

TcpClient class, 714

GetHue method, Color class, 480

GetString method

GetInt32 method

ResourceManager class, 763

processing record set, 535

processing record set, 535

GetType method Object class, 731 Object data type, 41

Type class, 730, 731, 844 GetTypeFromProgID method

Type class, 844, 845 GetTypes method

Assembly class, 730 GetValues method

NameValueCollection collection, 262 GetZip method

FindZipCodeClass class, 641 getzip.html

accessing FindZipCode Web service using, 647

global assembly cache see GAC

global functions CLS rules, 193

global methods CLS and, 20 global scope, 54 global variables CLS and, 20

CLS rules, 193 globalization, 764, 765

Globalization namespace, 202, 764, 765, 766 globalization tools, 765

granularity

GDI+ structures, 463 graphics

GDI+, 445–513

Graphics class, 201, 446, 454–459 Color structure, 480 CreateGraphics method, 455

deterministic cleanup of objects, 455 drawing custom shapes/lines, 492 Drawing methods, 480

DrawString method, 449, 472–475 extracting from bitmap, 503 instantiating, 455

rendering methods, 454–455 rendering outside Paint event, 455 TranslateTransform method, 460

GraphicsUnits, GDI+, 460 greater than (>) character, 347 greater than (>) operator, 62

I N D E X 873

green component G property, 480 GridLines property

ListView control, 380 GripStyle property

ToolStrip control, 404 GroupBox control, 336–340

groups of radio buttons, 340 RadioButton control and, 336

GuidAttribute class, 209

H

handle data type, 30 CTS data types, 19

handlers

Windows services, 607 handles

accessing reference object handle, 96 GCHandle class, 821

instantiating ref class objects, 95 reference data types, 96

passing handle by value to function, 76 pointers compared, 40

returning handles from functions, 78 String data type, 41

WaitHandle class, 663 Happy Face drawing

double buffering, GDI+, 503–508 drawing custom shapes/lines, 492 optimizing GDI+, 499

printing, 509

single buffering, 501 HasAttributes property XmlReader class, 562

XPathNavigator class, 593 HasChildNodes property

XmlNode class, 583 HasChildren property

XPathNavigator class, 593 hash (#) character, 346

hash (#) symbol

see preprocessor directives Hashtable collection, 251–255

Add method, 252 Capacity property, 252 Clear method, 252 ContainsKey method, 253

874 I N D E X

ContainsValue method, 253 description, 241 GetEnumerator method, 252 key/value pairs, 252, 253 load factor, 252

namespace, 196 Remove method, 252

SortedList compared, 251 HasValue property

XmlReader class, 562 HatchBrush class, 486

constructor, 487 HatchStyle enumerations, 486 header declaration

XML documents, 560 header files

assemblies, 149

“Hello World” Win Forms style, 311 libraries, 145, 146

HeaderStyle property ListView control, 380

heaps

CRT/managed heaps, default, 92 Height property

Font class, 476 Image class, 490

Rectangle/RectangleF structures, 465 Size/SizeF structures, 464

Hello World program, 27–28 GDI+ style, 447–449

Win Forms style, 310–314 Helplink property

Exception class, 168 hexadecimal numbers, 56 Hidden attribute, files, 286 hidden virtual overriding, 107 Horizontal enumeration

HatchStyle enumeration, 486 HorizontalResolution property

Image class, 490 Hosting namespace, 213 HotTrack property

TabControl control, 395 HoverSelection property

ListView control, 380 HResult

error handling, 166

HtmlControls namespace, 214 HTTP GET

caution: not using HTTP GET, 636 Http namespace, 210

HTTP POST

accessing Web service using, 646–647 caution: not using HTTP GET, 636 FindZipCode’s HTTP POST request, 645 FindZipCode’s HTTP POST response, 645 Web services communication protocols, 636

HTTP request SOAP wrapper, 644 HTTP response SOAP wrapper, 644 hue

GetHue method, 480 Hungarian notation, 32 HybridDictionary collection, 258

Collections::Specialized namespace, 196 description, 241

I

I1/I2/I4/I8 values

UnmanagedType enumeration, 834 IAsyncResult class, 721, 722, 724

AsyncState property, 723, 725 ICollection interface, 243 ICollection<T> interface, 243 IComparable<K> interface

Dictionary<K,V> collections, 273 IComparer interface, 243 IComparer<K> interface

Dictionary<K,V> collections, 273 IComparer<T> interface, 243

Icon class, 446 Icon property

ErrorProvider control, 426 Form class, 315 NotifyIcon control, 430

icons

ArrangeIcons method, 380 changing/matching icon sizes, 433 DrawIcon method, 454

LargeIcon mode, 379 NotifyIcon control, 430–433 SetIconAlignment method, 426

SetIconIconPadding method, 426 SmallIcon mode, 379 SystemIcons class, 447

identifiers

see context-sensitive keywords Identity property

IPrincipal interface, 778 IDictionary interface, 243 IDictionary<K,V> interface, 243

IDictionaryEnumerator interface, 243, 762 IDispatchImplAttribute class, 209 IDisposable interface

delete operator, 105

releasing unmanaged memory, 104 resource management destructors, 105

IEnumerable interface, 243–244 description, 243 GetEnumerator method, 243

IEnumerable<T> interface, 243 GetEnumerator method, 243 IEnumerator interface, 243–244

MoveNext method, 244 Reset method, 244

IEnumerator<T> interface, 243 MoveNext method, 244 Reset method, 244

if (#if) directive, 142–143 description, 140

if statement, 69–70 if-else statement, 69

if-else-if-else construct, 69 ifdef (#ifdef) directive

database connection strings, 531 debugging Windows services, 632

I/O

file system, 279–302 I/O manipulation, 291–302

class hierarchy for, 291

using BinaryReader/BinaryWriter, 299–302 using StreamReaders/StreamWriters, 297–299 using streams, 291–297

Ignore type DialogResult, 436 IgnoreComments property

XmlReaderSettings class, 571 IgnoreWhiteSpace property

XmlReaderSettings class, 571 IHashCodeProvider interface, 243 IIdentity interface, 777

ildasm tool

invoking Interop Assembly, 842 seeing differences Madd/UMadd, 808

I N D E X 875

IList interface, 243 selection controls, 358

IList<T> interface, 243 Image class

manipulating images, 490 members, 490 namespace, 446

rendering existing images, 490 unit of measurement used, 490

Image property ButtonBase class, 327 Label control, 324 PictureBox control, 420

ToolStripMenuItem control, 415 ImageAlign property

Label control, 324 ImageIndex property TabPage class, 395

ToolStrip control, 405 TreeNode class, 389 TreeView control, 387

ImageList component, 377–379 creating, 377

inheritance, 377 properties, 378

ImageList property TabControl control, 395 ToolStrip control, 405 TreeView control, 387

images

CenterImage mode, 420

displaying different image file types, 420 doubling image’s size, 492

DrawImage method, 454, 490 DrawImageUnscaled method, 454, 489, 490 LargeImageList property, 380

loading different image file types, 492 rendering existing images, 489–492 SelectedImageIndex property, 387, 389 SmallImageList property, 380 StretchImage mode, 420

stretching image, 490 TextImageRelation property, 405 TextureBrush using, 487

Images Collection Editor dialog box, 378 ImageScaling property

ToolStrip control, 405

876I N D E X

ImageSize property ImageList component, 378

Imaging namespace, 24, 200, 201 System::Drawing, 446 System::Web::UI, 214

immutability

String data type, 41

imperative role-based security, 781 implicit virtual overriding, 107 import (#import) directive, 140 ImportNode method

XmlDocument class, 585 InAttribute class, 209

Inch units

GDI+ GraphicsUnits, 460

include (#include) directive, 143–144 description, 140

syntax search methods, 144 INCLUDE environment variable

support for, 144 include tag

example using, 239

integrated XML documentation, 233 IncludeLiteral property

MaskedTextBox control, 346 IncludePrompt property

MaskedTextBox control, 346 increment operator, 61

Indent property TreeView control, 387

XmlWriterSettings class, 574 IndentChars property

XmlWriterSettings class, 574 indents

BulletIndent property, 353 SelectionHangingIndent property, 353 SelectionIndent property, 353 SelectionRightIndent property, 353

Index property TreeNode class, 389

indexed properties

default indexed property, 126 member properties, ref class, 124

IndexOf method Array class, 372

IndexOfKey method SortedList collection, 253

IndexOfValue method SortedList collection, 253

indices

CheckedIndices property, 368

FindIndex method, List<T> collection, 267 FindLastIndex method, List<T> collection, 267 GetByIndex method, 251, 253

ImageIndex property, 387, 389, 395, 405 SelectedImageIndex property, 387, 389 SelectedIndex/SelectedIndices properties, 359

indirection operator (*), 66, 67 infinity

IsInfinite method, 469 MakeInfinite method, 469

inheritance

CLS rules, 193

collection namespaces, 241 controls, 323

ImageList component, 377 namespace hierarchy, 194

inheritance, OOP, 86 Cube ref class, 94

protected: access modifier, 91 ref class benefits, 92

ref class drawbacks, 93 ref classes, 93

sealed ref class, 95

software development using objects, 88 unmanaged classes, 93

Initial Catalog clause connection strings, 530

InitializeComponent method Button control, 329

InitializeComponent method, 767, 768, 770 caution: making changes to, 316

Form class, 315 initializer list

ref class constructors, 101 InnerException property

Exception class, 168 InnerText property

XmlNode class, 583 InnerXml property

XmlNode class, 583 InputText property

MaskedTextBox control, 346

InsertAfter method XmlNode class, 584

writing XmlNodes in DOM trees, 591 InsertAuthor stored procedure, 526 InsertBefore method

XmlNode class, 584

writing XmlNodes in DOM trees, 591 InsertCommand property

DataAdapter classes, 550 InstalledFontCollection class, 479 InstallUtil command, 612, 613 Int16/Int32/Int64 data types, 33, 34 integer data types, C++/CLI, 33–35 integer numbers, 56

Integrated Security clause connection strings, 530

integrated XML documentation, 217–240 autogenerated documentation, 229 avoiding less than (<) symbol, 223 creating bulleted list, 231

creating definition of term, 232 creating numbered list, 232 creating table, 232

describing functionality of type/member/field, 223–228

documentation tags, 223–236 c tag, 229

code tag, 230 example tag, 226 exception tag, 228 include tag, 233 list tag, 231

para tag, 230 param tag, 224 paramref tag, 235 permission tag, 228 remarks tag, 226 returns tag, 225 see tag, 235 seealso tag, 236 summary tag, 224 value tag, 225

documenting exceptions thrown by methods, 228

documenting method access permissions, 228 documenting method parameters, 224, 235 documenting methods, 225

documenting object information, 226 documenting property values, 225

I N D E X 877

example using documentation tags, 236–239 external XML file information, 233 formatting tags, 229–233

functionality tags, 223–228

Generate XML Documentation Files property, 220

generated XML documentation, 221 mandatory tag, 224

NDoc generated documentation, 221 nesting of tags, 223

non repeatable tags, 224

providing formatting to tags, 229–233 reference tags, 233–236

referencing other documentation sources, 233–236

splitting into multiple paragraphs, 230 supplying code examples, 226, 230 triple slash (///) comments, 218–219

adding to code, 219–220 generating files from, 220–222

types of tags, 223

viewing in IntelliSense, 222–223 white space, 219, 229

<code> tag, 230 <c> tag, 229 <para> tag, 230

IntelliSense

using assembly metadata, 9

viewing integrated XML documentation in, 222–223

caution: deleting XML documentation file, 222

InteractiveProcess service, 607 interface class keywords

interfaces, C++/CLI, 135 interface types

CTS data types, 19 interfaces, C++/CLI, 51, 135–137

.NET collection interfaces ICollection interface, 243 IComparer interface, 243 IDictionary interface, 243

IDictionaryEnumerator interface, 243 IEnumerable interface, 243–244 IEnumerator interface, 243–244 IHashCodeProvider interface, 243 IList interface, 243

.NET generic collection interfaces, 243

.NET standard collection interfaces, 243