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

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

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

908 I N D E X

Join method, 666, 673 Name property, 666, 670 obsolete methods, 676 Priority property, 665, 666 ResetAbort method, 671 Resume method, 666, 676 Sleep method, 666, 669, 675

sleep/interrupt functionality, 676 Start method, 666, 667

Suspend method, 666, 676 suspend/resume functionality, 676

thread deadlock condition multithreaded programming, 692

ThreadAbortException exception, 671, 673 threading

see also multithreaded programming aborting threads, 671–673 apartment state, 311

CurrentThread class, 770 CurrentThread property, 666, 670, 766 generic collection classes, 264

getting thread to sleep, 669–671 how thread pool works, 678

interrupting/suspending/resuming threads, 675–677

joining threads, 673–674 multithreading, 212 ParameterizedThreadStart delegate, 698 ProcessThread class, 199

starting threads, 666–669 synchronization, 679–693 System::Threading namespace, 662–663 thread priorities, 665

thread state, 663–665

using ThreadPools, 677–679 using threads, 666–677 Windows services, 615

Threading namespace, 24, 212, 662–663, 680–693 ThreadPool class, 213, 663

how thread pool works, 678 keeping main thread alive, 679

QueueUserWorkItem method, 678, 679 using ThreadPools, 677–679

threads

see threading ThreadStart delegate, 666 ThreadState property

Thread class, 666

ThreadStateException exception, 671, 673 ThreadStatic attribute, 738 ThreadStaticAttribute class, 680–682 ThreeDCheckBoxes property

CheckedListBox control, 368 ThreeState property

CheckBox control, 330 throw statement

throwing ApplicationExceptions, 170 Tick events

event handler accepting, 373 Tile enumeration

WrapModes enumeration, 487 TileFlipX/TileFlipY enumerations WrapModes enumeration, 487

TileFlipXY enumeration tiling using, 488

WrapModes enumeration, 487 tiling, 487

time

CreationTime property, 280 DateTime classes, 300, 425 DateTimeFormatInfo class, 202, 765 GetCreationTime method, 281, 285 GetLastAccessTime method, 281, 285 GetLastWriteTime method, 281, 285 LastAccessTime property, 280 LastWriteTime property, 280 ReceiveTimeout option, 719

Timer class, 213

Timer component, 373–376 Elapse handler, 616

event handler accepting, 373

event handler accepting Tick events, 373 methods, 374

single buffering, GDI+, 501 Windows services, 616

timers

ProgressBar control, 374 TimeSpan structure, 669 tlbimp tool, 839

common options, 840 ToArgb method

Color class, 480 TodayDate/TodayDateSet properties

MonthCalendar control, 423

tokens, XML, 564 see also nodes

ToKnownColor method Color class, 480

tool tips

AutoToolTip property, 405 ShowItemToolTips property, 405 ShowToolTips property, 395

ToolBar control, 215 ToolStrip compared, 404

toolbars

ToolStrip control, 404–409 Toolbox

adding controls to Win Forms, 324 ToolStrip control, 404–409

creating within Visual Studio 2005, 409 properties configuring tool strip, 404 properties configuring tool strip items, 405 ToolBar compared, 404

ToolStripItems, 404 ToolStripButton

ToolStrip control, 404 ToolStripComboBox

MenuStrip control, 414, 415 ToolStrip control, 404

ToolStripContainer control, 402–403 adding strip controls, 403

adding to Win Form, 403 aligning ToolStripPanels, 403 ContentPanel property, 403

ToolStripDropDownButton ToolStrip control, 404

ToolStripItems ToolStrip control, 404

ToolStripLabel ToolStrip control, 404

ToolStripManager class, 403–404 Merge method, 404

merging two strip controls, 404 properties, 403

ToolStripMenuItem control building menu, 414 menu development, 415 MenuStrip control, 414 properties, 415

ToolStripPanel control, 402–403 display multiple strip controls, 403

I N D E X 909

ToolStripSeparator MenuStrip control, 414 ToolStrip control, 404

ToolStripSplitButton ToolStrip control, 404

ToolStripTextBox MenuStrip control, 414 ToolStrip control, 404

ToolTip property TabPage class, 395

ToolTipText property ToolStrip control, 405

TooMany_Click event handler method Button control, 329

Top property

Rectangle/RectangleF structures, 466 ToString method

boolean literals, 57 numeric literals, 56 Object data type, 41

Trace class, 199 tracing

System::Diagnostics namespace, 199 Transaction property

SqlCommand class, 543 transactional database access

connected ADO.NET, 539–543 TransactionAttribute, 202 transactions

BeginTransaction method, 543 DataSet class, 546

rolling back, 539 SqlTransaction class, 543 transaction IsolationLevels, 543

using connected ADO.NET with transactions, 539–543

Transform method Region class, 469

Translate method Region class, 469

TranslateTransform method Brush class, 487

double buffering example, 508 Graphics class, 460

scrollable windows, GDI+, 496 single buffering, GDI+, 501

910I N D E X

transparency

alpha component, colors, 480 TransparentColor property

ImageList component, 378 TreeNode class

adding nodes to TreeView, 393 constructors, 388

using images, 389 Nodes property, 389, 393 properties, 389

TreeView control, 388–393 TreeView control, 215, 387–393

adding TreeNodes, 393 BeforeExpand event, 392 creating, 392

events, 388 properties, 387

replacing holder TreeNode, 393 TreeViewCancelEventHandler, 392

TreeView property TreeNode class, 389

TreeViewCancelEventHandler TreeView control, 392

triggers

implementing events, 187 triggering events, 185

Trimming property StringFormat class, 474

triple slash (///) comments, 218–219 adding to code, 219–220

caution: using in code declaration, 218 caution: using outside of classes, 218 caution: well-formed XML, 219 caution: white space ignored, 219

example using documentation tags, 236–239

generating XML documentation files from, 220–222

stretching over multiple lines, 219

viewing integrated XML documentation in IntelliSense, 222

trivial properties

member properties, ref class, 118 TrueForAll method, List<T> collection

using Predicate<T>, 267 Truncate method

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

Truncate value

FileMode enumeration, 289 trust

FullTrust permission, 784 try block

catching SystemExceptions, 170 exception handling described, 167 exceptions, ADO.NET, 531

nested try blocks, 172

processing XML documents within, 586 rethrowing exception, 172

throwing ApplicationExceptions, 171 TryEnter method

Monitor class, 684, 685 try/catch block

XmlException class, 567 type casting

ref classes, 131 Type class

examining metadata, 730 GetType method, 730, 731, 844

GetTypeFromProgID method, 844, 845 InvokeMember method, 845

Is properties, 732 namespace, 730 retrieving metadata, 731

type conversions

data types, C++/CLI, 53–54 Type Library Importer

see tlbimp tool type metadata

assemblies, 9 Typed DataSet

developing with disconnected ADO.NET, 554–556

typedef operator, 165–166 TypeDelegator class, 207, 730 typeid key, 730

types

see data types TypeValidationCompleted event

MaskedTextBox control, 346 TypeValidationEventArgs argument

IsValidInput property, 346 typography

GenericTypographic property, 474

U

U1/U2/U4/U8 values UnmanagedType enumeration, 834

UDDI (Universal Description, Discovery, and Integration)

Web Services discovery services, 637 UDP client

example, 710, 711 ReceiveTimeout option, 719

UDP server, 706

binding socket to IPEndPoint, 707 creating, 706

example, 709

receiving message, 707, 708 sending message, 708 using Connect, 711, 712

UdpClient class, 717, 719 asynchronous functionality, 721 BeginReceive method, 724, 725 BeginSend method, 724 Receive method, 717

Send method, 719 UI namespace, 24, 214

UInt16/UInt32/UInt64 integer data types, 33, 34 caution using UInt64, 20

UIPermission class, 784 UMadd

comparing to Madd, 808 unary operators

overloading, 114 UnauthenticatedPrincipal value

PrincipalPolicy enumeration, 778, 779 unboxing

data types, C++/CLI, 51–52 undef (#undef) directive, 141 Underline property

Font class, 477 underscores

variable naming restrictions, 31 undo

CanUndo property, 344 ClearUndo method, 344

Undo method RichTextBox control, 354 TextBoxBase class, 345

UndoActionName property RichTextBox control, 353

I N D E X 911

Unicode character literal

creating from char (8-bit) type, 58 Unicode character set, 40

Unicode value

CharSet enumeration, 831 Unicode version

adding W to Windows functions, 831 Union method

Rectangle/RectangleF structures, 466 Region class, 469

UnionCodeGroup class, 786 UniqueConstraint

Constraint classes, ADO.NET, 548 Unit property

Font class, 477

Universal Description, Discovery, and Integration (UDDI), 637

unmanaged arrays, 810 unmanaged classes

access modifiers, 94

declarations compared to managed classes, 812

mixing with managed classes, 812 unsafe code, 94

unmanaged classes/struts, 811–815 unmanaged code, 806

unmanaged resources cleaning up, 105

UnmanagedType enumeration common values, 834

Unrestricted value

PermissionState enumeration, 784 unsafe classes

see unmanaged classes unsafe code, 13, 825

accessing COM components from .NET, 837–846

arrays data type, 47 catch block, 176 class/struct data types, 44 creating, 807

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

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

modifying dereferenced value, 68

912 I N D E X

neccessity of, 806, 807 new operator, 46 P/Invoke, 825–833

pointer to unmanaged data type, 98 pointers, 30, 815

interior pointers, 815, 816, 817 pinning interior pointers, 819, 820 pinning pointers, 817, 818, 819 within ref classes, 93

standard main function, 81 static_cast operator, 131 unmanaged arrays, 810 unmanaged classes, 94 unmanaged classes/struts, 811–815

unsafe programming, 805 unsigned integer data types, 33 Unstarted state

multithreaded programming, 664 Update method

committing/rolling back changed rows, 554 DataAdaptor classes, 546

deleting rows from data source, 553 inserting rows into data source, 552 updating rows in data source, 553

UpdateCommand property DataAdapter classes, 550

UrlMembershipCondition class, 786 UseMnemonic property

Label control, 325 User context

Windows services, 608 user defined data types, 42–51 user defined value types

CTS data types, 19 User ID clause

connection strings, 531 User policy statements, 785 using (#using) directive, 144

assembly referencing, 155, 194 caution: CLR finding, 145 description, 140

using keyword, 145 using statement, 28

utility structures, GDI+, 462–471

V

Validating event Control class, 352

ValidatingType property MaskedTextBox control, 345

validation

validating XML file, 569–574 ValidationEventHandler

delegating event handler, 573 handling invalid XML, 573

ValidationType property XmlReaderSettings class, 571

validation using DTD, 571 value data types, 42–45

Value property StructLayoutAttribute class, 836 XmlNode class, 584

XmlReader class, 563 XPathNavigator class, 593, 596

value struct/value class data types, 44 difference between, 44 inheritance, 45

value tag

example using, 237

integrated XML documentation, 225 value types

common type system, 17

language keywords for data types, 19 ValueAs method

XPathNavigator class, 594 ValueAs property

XPathNavigator class, 593 ValueCollection class

Dictionary<K,V> collections, 274 ValueMember property

ListControl class, 359 values

ContainsValue method, 253, 261–263 GetValues method, 262

HasValue property, 562 IndexOfValue method, 253 IsValueType property, 733 KeyValuePair<K,V> element type, 274 NameValueCollection, 261–263 ReadAttributeValue method, 563

returning values from functions, 77–79

SelectedValue property, 359 WriteValue method, 575

variables, C++/CLI, 29–55 declaring variables, 29–31

constructor initialization, 30 functional notation, 30

initializing within declaration statement, 30, 31

multiple variable declarations, 30 uninitialized variables warning, 31

Hungarian naming notation, 32 naming restrictions, 31–32

context-sensitive keywords, 32 reserved keywords, 31 underscores, 31

scope, 54

self-descriptive naming, 32 vcclr.h file, 820, 821, 822 verification

code access verification, 14 Version class, 195

versioning, 749, 750 assemblies, 9

getting version number, 751 setting version number, 750

Vertical enumeration HatchStyle enumeration, 487

VerticalResolution property Image class, 490

view controls, 379–393 ListView control, 379–386 TreeView control, 387–393

View Design window, 523 View property

ListView control, 379 views

creating database views, 522–524 DataGridView control, 556–558 DataView class, 198

ListView control, 379–386 TreeView property, 389 TreeViewCancelEventHandler, 392

virtual keyword

method declarations, 106 virtual member methods

static member methods and, 100

I N D E X 913

virtual methods

explicit (named) virtual overriding, 107 hiding pure virtual methods, 111 hiding virtual overriding, 107

implicit virtual overriding, 107 method overriding, 111 polymorphism, 106

pure virtual method, 111 sealing, 133

visibility

EnsureVisible method, 380 Visibility property

CheckBox control, 330 Visible property

NotifyIcon control, 430 Panel control, 340

Visual Studio .NET

generating COM Interop Assembly, 840, 841 Visual Studio 2005

building database with, 517–526 Visual Studio. NET

invoking Interop Assembly, 842 VisualStylesEnabled property

ToolStripManager class, 404 void parameter

main function, 28

W

W3cXsd2001 namespace, 210 Wait method

Monitor class, 685, 687 WaitForStatus method

ServiceController class, 628 WaitHandle class, 663 WaitOne method

Mutex class, 689 WaitSleepJoin state

multithreaded programming, 664 wchar_t alias, Char data type, 39 Web applications

application development, 22 Web namespaces, 24, 213, 638, 775 Web Service GUI Designer tool

passing data using, 652–653

914I N D E X

Web services, 635–659

accessing using HTTP POST, 646–647 accessing using SOAP, 647–650 application development, 22 ASP.NET Web Service template, 638 C++/CLI support, 638 communication protocols, 636–637

HTTP POST, 636 SOAP, 637

components of, 636–637

console Web services client application, 649 creating Web service, 638–645

debugging, 650–651

client and Web service scenarios, 651 debugging Web service error, 650

description service, 636 discovery service, 636, 637

guaranteeing unique namespace, 641 making members accessible, 641 namespaces, 638

passing data using, 651–659

DataSet processing Web Service client, 655–659

inserting/updating/deleting rows in DataSet, 654–655

returning DataSet, 653–654

Web Service GUI Designer tool, 652–653 Resource can’t be found error, 642

Unable to load DLL ‘msvcm80d.dll’ error, 642 Web Services Description Language, 637 WebMethod attribute, 641 WebMethodAttribute, 638

WebService attribute, 640 WebService class, 638 WebServiceAttribute, 638

Web Services Description Language (WSDL) EmitConformanceClaims property, 640 FindZipCode’s WSDL, 642

Web Services Discovery tool (DISCO), 637 Web Services Interoperability (WSI)

ConformsTo property specifying, 640 Web::Mail namespace, 24 Web::Security namespace, 24 Web::Services namespace, 24

Web::UI namespace, 24 WebControls namespace, 214 WebMethod attribute, 641, 642, 738

WebMethodAttribute Web services, 638

WebService attribute, 640, 642, 738 WebService class, 638 WebServiceAttribute, 638 WebServiceBinding attribute

ASP.NET Web Service template, 640 well formed XML

verifying, 569 while loop, 71–72

continue statement, 75 do while loop, 72–73

white space

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

IgnoreWhiteSpace property, 571 integrated XML documentation, 219, 229 <para> formatting tag, 230 PreserveWhitespace property, 584 SetIconIconPadding method, 426 SignificantWhitespace node type, XML, 564 WriteWhitespace method, 575 XmlSignificantWhitespace class, 582 XmlWhitespace class, 582

Whitespace node type, XML, 564 width

SplitterWidth property, 399 Width property

Image class, 490 Pen class, 482

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

Windows namespace, 24, 214 Win Forms

.NET application development, 21 adding controls, 323

container controls, 394–402 controls, 323

developing with disconnected ADO.NET, 549–558

dialog boxes, 434–444 ErrorProvider control, 426 handling delegates/events, 319–323 Hello World program, 310–314 ImageList component, 377

Microsoft Foundation Classes and, 309 MonthCalendar control, 423

NotifyIcon control, 430 PictureBox control, 420 strip controls, 402–420 view controls, 379–393 Win32 namespace, 23, 216

Win32OwnProcess service, 606, 607 Win32ShareProcess service, 606, 607 winapi value

CallingConvention enumeration, 831 windows

scrollable windows, 494–497 Windows applications

application development, 21 Windows Forms

see Win Forms Windows services, 605–634

application development, 22 architecture of, 607–609 automatically generated, 610, 612

conversion for safe code, 612, 613 SimpleWinService.cpp code, 611 SimpleWinService.cpp for safe code, 612 SimpleWinService.h code, 613

confusing name, 605 creating, 609–621 customizing, 615–621

SimpleWinService.h code, 619 debugging, 630–633

attaching debugger to Windows Service, 631–632

special main function, 632–633 description, 605–607

event handler trigger methods, 629 handlers, 607

installed as, 606 installers, 610

installing/uninstalling, 621–624 interface to outside world, 607 managing, 624–630

multiple services, 606

OnContinue event handler, 613, 618 OnCustomCommand event handler, 613, 630 OnPause event handler, 613, 618 OnShutdown event handler, 613

OnStart event handler, 613, 615–617 OnStop event handler, 613, 617 operating system communication, 607

I N D E X 915

operating systems, 605 path to, 606

querying/retrieving properties of, 608 registry executable object, 607 running, 605

security contexts, 608 service application, 607

service configuration application, 607, 608–609 service control application, 607, 608

Service Control Manager (SCM), 607 ServiceController class, 626–630 service processes, 605

ServiceBase class, 609–621 ServiceController class, 609, 626–630 ServiceInstaller class, 609, 621–624 ServiceProcess namespace, 609 ServiceProcessInstaller class, 609, 621–624 Services application, 625–626

custom service control application, 626–630 single service, 606

starting/stopping, 608 starting manually, 608 template, 610 threads, 615

type of service being accessed, 607 types, 607

user interface, 605 Windows::Forms namespace, 24, 214 WindowsIdentity object, 776, 779

WindowsPrincipal object, 777, 778, 779, 780 WindowState property

Form class, 315 WinMain function, 28 WordWrap property

TextBoxBase class, 344 wprintf function, 822 WrapMode parameter

TextureBrush class, 487 WrapModes enumeration TextureBrush class, 487

wrapping

LabelWrap property, 380 WordWrap property, 344

Write method BinaryWriter class, 300 Stream class, 292 StreamWriter class, 298

916I N D E X

Write value

FileAccess enumeration, 289 FileShare enumeration, 290

WriteByte method, Stream class, 292 WriteContentTo method

XmlNode class, 584 WriteLine method

Console class, 28 StreamWriter class, 298

WriteState property XmlWriter class, 575

WriteTo method MemoryStream class, 295 XmlNode class, 584

WriteXyz methods XmlWriter class, 575

WSDL (Web Services Description Language), 637

X

X property

MouseEventArgs class, 319 Point/PointF structures, 463 Rectangle/RectangleF structures, 466

X value

TileFlipX enumeration, 487 XML

.NET Framework XML implementations, 560–561

ADO.NET and XML, 601–603 definition, 559

forward only access, 561–580 delegating event handler, 573 reading from XML file, 562–568 SAX compared, 561

updating existing XML file, 578–580 validating XML file, 569–574 writing new XML stream, 574–578

handling invalid XML, 573 introduction, 559–560

navigating with XPathNavigator, 593–601 verifying well formed, 569

working with DOM trees, 581–592 XML documents, 559

attributes, 560 comments, 560 components, 559

DOM storing and manipulating, 581

elements, 559

header declaration, 560 integrated XML documentation

see integrated XML documentation loading and saving, 584

loading into XmlDocument, 586 processing within exception try block, 586 WriteStartDocument method, 575 XmlReader processing, 564

XML namespace, 24, 215, 216, 561 XML namespaces, table of, 561 XmlAttribute class, 582 XmlCDataSection class, 582 XmlCharacterData class, 582 XmlComment class, 582 XmlDataDocument class, 582, 601

DataSet property, 601 methods, 601

XmlDeclaration class, 582 XmlDeclaration node type, XML, 564

CreateXmlDeclaration method, 585 XmlDocument class, 584

classes derived from XmlNode, 582 constructor, 586

creating nodes dynamically, 592 methods, 584

properties, 584 XmlDocumentFragment class, 582 XmlDocumentType class, 582 XmlElement class, 582

XmlEntity class, 582 XmlEntityReference class, 582 XmlException class, 567 XmlLinkedNode class, 582 XmlNode class

classes derived from, 582 creating nodes dynamically, 592 DOM trees and, 582

methods, 584 properties, 583

writing XmlNodes in DOM trees, 590–592 XmlNodeList, 584

XmlNodeReader class, 562 XmlNotation class, 582 XmlProcessingInstruction class, 582

I N D E X 917

XmlReader class

XPath class, 216

Create method, 562

XPath expressions

creating, 562

accessing DOM tree, 596

Depth property, 562, 567

accessing named parent nodes, 597

difference when validated, 572

accessing parent nodes at specified depth, 598

handling invalid XML, 573

accessing unnamed parent nodes, 598

implementing, 564

conditional expressions, 598

introduction, 562

logical operators, 599

methods, 563

making numeric comparisons, 599

prefixes, 563

matching attributes, 599

processing XML document, 564

specifying path or file, 597

properties, 562

XPathNavigator using, 596–601

reading from XML file, 562–568

XPath namespace, 561

updating existing XML file, 578–580

XPathNavigator class

XmlReaderSettings class, 569

CreateNavigator method, 584, 595

creating XmlReader class, 562

methods, 593

properties, 571

MoveToRoot method, 595

Reset method, 571

moving around DOM tree, 594–596

validating XML file, 571

properties, 593

XmlSignificantWhitespace class, 582

using recursion, 595

XmlText class, 582

using XPath expressions, 596–601

XmlTextReader class, 562

Value property, 593, 596

XmlTextWriter class, 574

XML navigation with, 593–601

XmlWhitespace class, 582

XSD (XML schema definition)

XmlWriter class

validating XML file, 569, 570

Create method, 575, 577

Xsl class, 216

introduction, 574

Xsl namespace, 561

methods, 575

Y

properties, 574

updating existing XML file, 578–580

Y property

writing new XML stream, 574–578

MouseEventArgs class, 319

writing XML file, 576

Point/PointF structures, 463

XmlWriterSettings class

Rectangle/RectangleF structures, 466

adding XML header, 577

Y value

indenting output, 577

TileFlipY enumeration, 487

introduction, 574

Yes type DialogResult, 436

properties, 574

Z

putting attribute on new lines, 577

writing XML document, 577

ZigZag enumeration

Xor method

HatchStyle enumeration, 487

Region class, 469, 471

 

XPath

 

operators, 600