Pro Visual C++-CLI And The .NET 2.0 Platform (2006) [eng]-1
.pdf888■I N D E X
OdbcXyz classes
see equivalent SqlXyz classes Offset method
Point/PointF structures, 463, 464 Rectangle/RectangleF structures, 465
offsetof operator
ref class drawbacks, 93 OK type DialogResult, 436
OLE DB managed provider, 526 connection strings, 531
OleDb namespace, 23, 516, 527 OleDbXyz classes
see equivalent SqlXyz classes OmitXmlDeclaration property
XmlWriterSettings class, 574 OnClick event
CheckOnClick property, 368, 415 OnContinue event handler, 613
customizing Windows services, 618 OnCustomCommand event handler, 613
Windows services, 630
ones compliment (~) operator, 63, 64 OnPaint method, Control class
PaintEventHandler compared, 450–453 prepackaged PaintEventHandler, 451
OnPause event handler, 613 customizing Windows services, 618
OnShutdown event handler Windows services, 613 OnStart event handler, 613
customizing Windows services, 615–617 debugging Windows services, 633
OnStop event handler, 613 customizing Windows services, 617 debugging Windows services, 633
OOP (object-oriented programming) abstract ref classes, 133–134 C++/CLI, 89–137
concepts in OOP, 85–89 encapsulation, 85 inheritance, 86
instantiating ref class objects, 95 interfaces, 135–137 introduction, 85 polymorphism, 86
ref classes/structs, 89–132 software development using, 87
Open method Connection classes, 531
File/FileInfo classes, 288, 289–290 Open value
FileMode enumeration, 289 OpenFileDialog dialog box, 442 OpenOrCreate value
FileMode enumeration, 289 OpenXyz methods
File/FileInfo classes, 288 OperatingSystem class, 195 operator overloading, 112
binary operators, 114
managed operator overloads, 115 supported managed operators, 113 unary operators, 114
operators, C++/CLI, 61–69 address of operator, 66 arithmetic operators, 61–62 assignment operators, 65–66 binary operators
overloading, 114 bitwise operators, 63–64 comma operator, 65 comparison operators, 62 conditional operator, 64 dot operator, 96
gcnew operator, 96 indirection operator, 66, 67 logical operators, 62
managed operator overloading, 112 precedence, 68
preprocessor operators, 142 reference operator, 66
scope resolution (::) operator, 101 type casting between class types, 131 typedef operator, 165–166
unary operators overloading, 114
optimization
optimizing GDI+, 498–501 OR (||) operator, 62
Oracle managed provider, 526 connection strings, 531
Oracle namespace, 516, 527 OracleXyz classes
see equivalent SqlXyz classes
ORDER BY clause, 522 Orientation property
SplitContainer control, 398 OutAttribute class, 209 OuterXml property
XmlNode class, 583 OutputText property
MaskedTextBox control, 346 overflow
CanOverflow property, 404 OverflowButton property
ToolStrip control, 405 overloading
functions, C++/CLI, 80 method overloading, 111
overriding
explicit (named) virtual overriding, 107 hiding virtual overriding, 107
implicit virtual overriding, 107 method overriding, 111
OwnerDocument property XmlNode class, 583
■P
P/Invoke
DllImportAttribute class, 830 CallingConvention field, 831 CharSet field, 831 EntryPoint field, 831 ExactSpelling field, 831 PreserveSig field, 832 SetLastError field, 832
unsafe code, 825 using, 828, 829
using as static method in class, 832, 833 padding
SetIconIconPadding method, 426 pages
DefaultPageSettings property, 509 PrintPage event handler, 512 TabPage control, 398
TabPages property, 395 PageSetupDialog dialog box, 442 PageUnit property, Graphics class
GDI+ GraphicsUnits, 460 PageUnit property for form, 462
rendering to new unit of measure, 462 utility structures, 463
■I N D E X 889
Paint event, Control class, 449 Graphics class rendering outside, 455 Hello World GDI+ style, 449
Paint event handler optimizing GDI+, 498
scrollable windows, GDI+, 495 Paint events
manually triggering, 459
OnPaint method vs. PaintEventHandler, 450–453
PaintEventArgs class
Hello World GDI+ style, 449 PaintEventHandler event handler Hello World GDI+ style, 449
OnPaint method compared, 450–453 parameters, 449
Panel control, 340–343 disabling/hiding panels, 343 Enable property, 340 Visible property, 340
Panel1/Panel1Collapsed properties SplitContainer control, 398
Panel2/Panel2Collapsed properties SplitContainer control, 398
panels
ContentPanel property, 403 FixedPanel property, 398 ToolStripPanel control, 402–403
para tag
example using, 238
integrated XML documentation, 230 param tag
example using, 237
integrated XML documentation, 224 parameter lists
CLS rules, 193 ParameterInfo class, 207, 730
ParameterizedThreadStart delegate, 698 parameters
functions, C++/CLI, 76 SqlParameters class, 534, 535
stored procedure using, 535 template parameters, 160–162
paramref tag example using, 239
integrated XML documentation, 235
890■I N D E X
parent classes
ref class drawbacks, 93 ref class inheritance, 93
Parent property TreeNode class, 389
ParentNode property XmlNode class, 583
updating DOM trees, 589 partial specialization, templates, 159 Password clause
connection strings, 531 PasswordChar property
TextBox control, 345 Paste method
TextBoxBase class, 344 Path class, 204
manipulating directory strings, 282 methods, 282
paths
FullPath property, 389 GetFullPath method, 282 ManagementPath class, 205 Xpath class, 216
XPath namespace, 561 XPathNavigator class, 593–601
Pause method ServiceController class, 628
pauses
CanPauseAndContinue property, 614, 628 OnPause event handler, 613, 618
Peek method
Queue collection, 256 Stack collection, 256 StreamReader class, 297
Pen class
CompoundArray property, 482 system pens, 485
constructors, 482 namespace, 446 properties, 482
Pens class, 446 SystemPens class, 447
pens, GDI+, 481–485 based on pen color, 482 based on pen style, 483 custom pens, 482 named pens, 482
namespaces, 484 system pens, 483–485
PenType property Pen class, 482
performance
throwing ApplicationExceptions, 170 performance counters, 199 PerformanceCounter class, 199 PerformanceCounterCategory class, 199 period (.)
see dot (.) Permission class
AddPermission method, 784 permission tag
example using, 238
integrated XML documentation, 228 permissions
code access security, 783, 784 code access verification, 14
Permissions namespace, 212, 776, 784 PermissionState enumeration, 784 Persist Security Info clause, 530 PhysicalDimensions property
Image class, 490
PictureBox control, 215, 420–422 AutoSize mode, 420 CenterImage mode, 420
displaying different image file types, 420 properties, 420
StretchImage mode, 420 pin_ptr <> keyword, 817
garbage collection, 14
pinning interior pointers, 819, 820 pinning pointers, 817, 818, 819 pipe (|) character, 347
Pixel units
GDI+ GraphicsUnits, 460 Plaid enumeration
HatchStyle enumeration, 486 platform independence
.NET Framework advantages, 6 C++/CLI programmers, 16 MSIL and, 11
platforms
multiple platform support, 16 PlayCards application
assembly referencing, 155 building library assembly, 151
plus
ShowPlusMinus property, 388 Point structure, 447, 462
Point units
GDI+ GraphicsUnits, 460 Point2D class template
template parameters, 160 pointer arithmetic
ref class drawbacks, 93 reference object handles and, 96 subscripting and, 48
Pointer class, 207 pointer types, 17, 30 pointers, 815
CLS and, 20 CLS rules, 193
handles compared, 40 interior pointers, 815, 816, 817
pinning interior pointers, 819, 820 pinning pointers, 817, 818, 819 pointer to unmanaged data type, 98 ref class benefits, 92
unsafe code, 30
pointers within ref classes, 93 Point/PointF structures, 462, 463–464
casting to Size/SizeF, 465
changing between Point/PointF, 463 members, 463
namespace, 447
Offset method, 463, 464 Round method, 463 Size/SizeF compared, 464 Truncate method, 463
points
EndPoint class, 708, 707 EntryPoint field, 831 EntryPoint string value, 831 IPEndPoint class, 707, 708, 710 SizeInPoints property, 476
Policy namespace, 212, 776, 786 policy statements
code access security, 784, 785 PolicyHierarchy method
SecurityManager class, 788 PolicyStatementAttribute class Exclusive attribute, 785 LevelFinal attribute, 785
■I N D E X 891
polymorphism
virtual methods, 106 polymorphism, OOP, 86
software development using objects, 88 Pop method
Stack collection, 256 ports
.NET Framework, 6 Ports namespace, 204
Position property, Stream class, 292 reading/writing to streams, 293
pound (#) symbol
see preprocessor directives pragma (#pragma) directive, 140
mixing managed/unmanaged code, 807, 808, 809
precedence
arithmetic operators, 62 bitwise operators, 64
comparison/logical operators, 63 operators, C++/CLI, 68
predefined colors
creating named colors, 481 predefined data types, 32–42 Predicate<T> delegate
List<T> collection, 265, 266 Exists method, 266
Find method, 266 FindAll method, 266, 267 FindIndex method, 267
FindLastIndex method, 267 FindList method, 267 TrueForAll method, 267 using, 266
prefixes
XmlReader class, 563 PrependChild method
XmlNode class, 584 preprocessor directives, 139
C++/CLI, table of, 140 conditional directives, 142–143 defining directives, 140–142 include (#include), 143
using (#using), 144 preprocessor operators, 142
defined/!defined, 143 PreserveSig field
DllImportAttribute class, 832
892■I N D E X
PreserveWhitespace property XmlDocument class, 584
Pressed property ToolStrip control, 405
Previous property LinkedListNode<T> collection, 270
PreviousSibling property XmlNode class, 583
PrevNode property TreeNode class, 389
primitive types CLS and, 20, 193
primitive value types, 19 Principal namespace, 212, 776 PrincipalPermission class
Demand method, 781 PrincipalPermissionAttribute class, 781 PrincipalPolicy enumeration
nullptr as first parameter, 781 UnauthenticatedPrincipal value, 778, 779
Print method PrintDocument class, 509
PrintController property PrintDocument class, 509
PrintDialog control
drawing Happy Face, 511, 512 PrintDialog dialog box, 442 PrintDocument class, 508
drawing Happy Face, 511 members, 509
Print method, 509 PrinterSettings property
PrintDocument class, 509 printing
GDI+, 508–512
Printing namespace, 24, 200, 201, 446 PrintPage event handler
drawing Happy Face, 512 Priority property
Thread class, 665, 666 private access modifier
adding to ref classes, 91 ref classes, 94 summarized, 91 unmanaged classes, 94
private assemblies, 7
private inheritance ref classes, 93 private members
ref class inheritance, 94 private methods
member methods, ref class, 99 Process class, 199
StartInfo property, 688 processes
creating one within another, 687 ProcessModule class, 199 ProcessStartInfo class, 199 ProcessThread class, 199 ProgIdAttribute class, 209 programming languages
.NET Framework advantages, 5 language keywords for CTS types, 19 MSIL language neutrality, 10 multiple language support, 15
ProgressBar control, 374, 376 ProhibitDtd property
XmlReaderSettings class, 571 properties
member properties, ref class, 118 ref class benefits, 92
PropertyData class, 205 PropertyDataCollection class, 205 PropertyInfo class, 207, 730
retrieving, 732 protected access modifier
ref classes, 91, 94 summarized, 91 unmanaged classes, 94
protected inheritance ref classes, 93
protected methods
member methods, ref class, 99 Protocols namespace, 638 prototypes
functions, C++/CLI, 79 providers
ErrorProvider control, 426–430 IHashCodeProvider interface, 243
Proxies namespace, 210 PtrToStringChars function, 822
public access modifier adding to ref classes, 90 summarized, 91 unmanaged classes, 94
public inheritance
ref class drawbacks, 93 public keyword
adding namespaces to libraries, 148 public members
accessing nested ref classes, 131 public methods
member methods, ref class, 99 Pulse method
Monitor class, 685, 687 PulseAll method
Monitor class, 685 pure virtual methods, 111
class deriving from abstract class, 133 interfaces, C++/CLI, 135
Push method
Stack collection, 256
■Q
QualifierData class, 205 QualifierDataCollection class, 205 qualifiers
const qualifier, 52
data types, C++/CLI, 52–53 queries
EventQuery class, 205 ExecuteNonQuery method, 536 ExecuteReader method, 532 ExecuteScalar method, 538 getting data from two tables, 522 ManagementQuery class, 205
returning single value from query, 538–539 question mark (?) character, 346
Queue collection, 255–257 Clear method, 256 Dequeue method, 256 description, 242 Enqueue method, 256 namespace, 196
Peek method, 256 Queue<T> collection, 271–272
description, 242 namespace, 197
■I N D E X 893
QueueUserWorkItem method
ThreadPool class, 678, 679
■R
R property
Color class, 480 R4/R8 values
UnmanagedType enumeration, 834 RadioButton control, 215, 334–336
AddRange method, 336 array of radio buttons, 336 CheckedChanged event, 336 GroupBox control and, 336 groups of radio buttons, 340 selecting more than one, 337
raise_<delegate-name> method, 185 Random class, 195
range
AddRange method, 336 SelectionRange property, 423
RCW (runtime callable wrapper) Interop Assembly as, 839
Read method SqlDataReader class, 535 Stream class, 292 StreamReader class, 297 XmlReader class, 563
Read value
FileAccess enumeration, 289 FileShare enumeration, 290
ReadAttributeValue method XmlReader class, 563
ReadBlock method StreamReader class, 297
ReadByte method Stream class, 292
ReadCommitted transaction isolation levels, 543 ReadContentAs method
XmlReader class, 563 ReadElementContentAs method
XmlReader class, 563 ReadElementString method XmlReader class, 563 ReadEndElement method XmlReader class, 563
894■I N D E X
ReaderWriterLock class, 213, 663, 691–693 AcquireReaderLock method, 691 AcquireWriterLock method, 692 constructors, 691
ReleaseReaderLock method, 692 ReleaseWriterLock method, 692 thread deadlock condition, 692
ReadLine method StreamReader class, 297, 298
ReadNode method XmlDocument class, 585
ReadOnly attribute, files, 286 ReadOnly property
TextBoxBase class, 344 ReadOnlyCollection<T> class, 197, 242, 278 ReadStartElement method
XmlReader class, 563 ReadState property
XmlReader class, 563 ReadString method
XmlReader class, 563 ReadToEnd method
StreamReader class, 297, 298
ReadUncommitted transaction isolation levels, 543
ReadWrite value
FileAccess enumeration, 289 FileShare enumeration, 290
ReadXyz methods BinaryReader class, 300
Receive method
Socket class, 699, 704, 711, 712 UdpClient class, 717
ReceiveFrom method Socket class, 708, 719, 720
ReceiveTimeout option UDP client, 719
RecognizerDriver service, 607 record set
processing, 535
Rectangle/RectangleF structures, 447, 462, 465–468
Contains method, 465, 466 Intersection method, 465, 466 members, 465
Union method, 466
red component
R property, 480 redo
CanRedo property, 353 Redo method
RichTextBox control, 354 RedoActionName property RichTextBox control, 353
ref classes
abstract ref classes, 133–134 access modifier, adding private, 91 access modifier, adding public, 90
accessing reference object handle, 96 caution: accessing unmanaged resources, 96 constructors, 101
copy constructor, 102 initialization values, 101
static ref class constructors, 103 Cube ref class, 94
declaring, 89
default member access, 89, 90 delegates, 179
destructors, 104
memory management destructors, 104 resource management destructors, 105
difference between ref class/struct, 89 drawbacks, 93
inheritance, 93 initializer list, 101 initializing variables, 97 instantiating objects, 95 introduction, 89
member methods, 98–118 member properties, 118–128 member variables, 97 method overloading, 111 method overriding, 107, 111 methods, 95
nested ref classes, 128 operator overloading, 112 private access modifier, 94 private inheritance, 93 protected access modifier, 94 protected inheritance, 93 reference data types, 96 sealed ref class, 95
Square ref class, 90
static member methods, 100 static member variables, 98 type casting, 131
using, 95–97
virtual methods, 106
explicit (named) virtual overriding, 107 hiding virtual overriding, 107
implicit virtual overriding, 107 pure virtual method, 111
ref keyword, 92–93 garbage collection, 14
ref structs, 89
see also ref classes reference class types CTS data types, 19
reference data types, 32, 40–42, 46–51 gcnew operator, 46
ref class objects, 96 reference operator (%), 66 reference tags
integrated XML documentation, 233–236 reference types
common type system, 17
language keywords for data types, 19 passing arguments by, 76
ReferenceEquals method Object data type, 41
references
returning references from functions, 78 referencing
assembly referencing, 154–155 reflection, 729
common language runtime, 15
dynamically invoking or late-binding objects, 735, 736, 738
examining objects, 730
getting metadata, 731, 733, 735 getting Type reference, 730, 731
metadata, 15
Reflection namespace, 24, 206, 207, 729, 730, 735
Refresh method
ServiceController class, 628, 629 Region class
brief description, 462 building, 471 displaying Region, 470
■I N D E X 895
GDI+, 469–471 methods, 469
code illustrating, 470 methods returning void, 471 namespace, 447
Xor method, 469, 471 RegionInfo class, 203, 765 regions
FillRegion method, 471 RegistrationServices class, 209 Registry class, 216
registry executable objects Windows services, 607
RegistryKey class, 216 RejectChanges method DataSet class, 546
committing/rolling back rows, 554 developing with DataGridView control, 557
relationships
“contains a” relationship, 128
creating relationships between tables, 520–522 DataRelation class, 548 DataRelationCollection class, 547
Foreign Key Relationships property page, 521 “is a” relationship, 128
TextImageRelation property, 405 XmlDataDocument class, 601
ReleaseComObject method Marshal class, 839
ReleaseMutex method Mutex class, 689
ReleaseReaderLock method ReaderWriterLock class, 692
ReleaseWriterLock method ReaderWriterLock class, 692
remarks tag
example using, 237
integrated XML documentation, 226 non repeatable tags, 224
Remoting namespace, 24, 209, 210 Remove method
delegates, 185
Dictionary<K,V> collections, 274 Hashtable collection, 252 NameValueCollection collection, 262 removing delegates from multicast chain, 181 SortedList collection, 252
896■I N D E X
remove_<delegate-name> method, 185 RemoveAll method
XmlNode class, 584 RemoveAt method
SortedList collection, 252 RemoveChild method
CodeGroup class, 786, 789 XmlNode class, 584
RemoveXyz methods LinkedList<T>, 270
Renderer property ToolStripManager class, 404
rendering
compatibility with .NET 1.1, 311 double buffering, 501–508 rendering existing images, 489–492
rendering methods Graphics class, 454–455
RenderMode property ToolStrip control, 405 ToolStripManager class, 404
reordering
AllowColumnReorder property, 379 AllowItemReorder property, 404
RepeatableRead transaction isolation levels, 543 ReplaceChild method
XmlNode class, 584 reserved keywords
variable naming restrictions, 31 Reset method
IEnumerator interface, 244 XmlReaderSettings class, 571
ResetAbort method Thread class, 671
ResGen utility, 757, 758 resgen.exe
resources in .NET, 11 resigning assembly, 749 resolution
HorizontalResolution property, 490 VerticalResolution property, 490
resource management destructors, 105 ResourceManager class, 208, 762, 763
GetObject method, 763 GetString method, 763 localization tools, 767
supporting culture-specific resources, 765
ResourceReader class, 208, 762, 763 Close method, 762 GetEnumerator method, 762 MoveNext method, 762
resources
accessing resources, 762 ResourceManager class, 762, 763 ResourceReader class, 762
AddResources method, 757 ApplyResources method, 769 assemblies, 11
building text name/value pair resource files, 756
ComponentResourceManager class, 769 creating, 756
embedding resources, 758, 759, 760 introduction, 755, 756
ResGen utility, 11, 757 ResourceWriter class, 757
Resources namespace, 24, 207, 208, 757 ResourceWriter class, 208
AddResources method, 757 Close method, 757
Resume method Thread class, 666, 676
Retry type DialogResult, 436 return statement, 77
return type
functions, C++/CLI, 76
returning values from functions, 77–79 returns
AcceptReturn property, 345, 347 returns tag
example using, 237
integrated XML documentation, 225 non repeatable tags, 224
Reverse method Array object, 48
ArrayList collection, 247 revision version, 749
RichTextBox control, 215, 352–358 Anchor property, 357 assigning text to, 352 formatting features, 352
implementing functionality, 357 implementing simple RTF editor, 354 properties, 353
resizing parent window, 357 updating properties, 357
Right property
Rectangle/RectangleF structures, 466 right shift (>>) operator, 63, 64 RightMargin property
RichTextBox control, 353 role-based security, 211, 776
identities, 776, 777 principal objects, 777
securing code using roles, 780, 781, 782, 783
working with identities/principals, 778, 779, 780
Rollback method SqlTransaction class, 543
rolling back, 539 root node
MoveToRoot method, 594 roots
gcroot<T> template, 821 MoveToRoot method, 595 ShowRootLines property, 388 SyncRoot property, 264
RotateFlip method Image class, 490
Round method
Point/PointF structures, 463 Rectangle/RectangleF structures, 466 Size/SizeF structures, 464
rows
committing/rolling back changed rows, 554 DataRow class, 547
deleting from data source, 553 FullRowSelect property, 380 GetElementFromRow method, 601 GetRowFromElement method, 601 GetRowFromElement method, 601 inserting into data source, 552 selecting from DataSet, 551 updating in data source, 553
RTF (Rich Text Format)
implementing simple RTF editor, 354 SelectedRtf property, 353
Rtf property
RichTextBox control, 353 Run method
Application class, 311 ServiceBase class, 613
■I N D E X 897
Running state
multithreaded programming, 664 runtime callable wrapper (RCW), 839
Runtime namespaces, 24, 208, 209, 210, 211, 821, 829, 834
runtimes
common language runtime, 11
■S
safe code
automatically generated Windows services, 612, 613
safe_cast operator, 54
exception handling described, 167 type casting between class types, 131 verifying, 131
safe/unsafe code, 13 saturation
GetSaturation method, 480 Save method
Image class, 490 XmlDocument class, 585
SaveFile method RichTextBox control, 354
SaveFileDialog dialog box, 442 SavePolicy method
SecurityManager class, 788 SAX (Simple API for XML)
XML forward only access compared, 561 SByte integer data type, 33
scalability
common language runtime, 13 scalar properties, 119
scaling
ImageScaling property, 405 Schema class, 216
Schema namespace, 561 Schemas property
XmlReaderSettings class, 571 scope
global scope, 54 local variables, 54
variables, C++/CLI, 54 scope resolution (::) operator
accessing static member method, 101 accessing static property, 122
implementing member methods in namespaces, 148