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

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

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

898I N D E X

scrollable windows, GDI+, 494–497 AutoScrollMinSize property, 494 enabling automatic scroll bars, 494

ScrollBar class, 215 Scrollbars property

RichTextBox control, 353 scrolling

AutoScroll property, 315 AutoScrollMinSize property, 494 AutoScrollPosition property, 496 Panel control, 340

scrollable windows, GDI+, 494–497 sealed ref class, 95

security, 775

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–802

cryptography, 211

Integrated Security clause, 530 MSIL and metadata, 11 namespaces, 775

Password clause, 531

Persist Security Info clause, 530 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

SQL Server, 518 security contexts

Windows services, 608

Security namespaces, 24, 211, 212, 776, 784, 786 System::Net, 206

System::Web, 213 SecurityIdentity class, 202 SecurityManager class

PolicyHierarchy method, 788 SavePolicy method, 788

SecurityPermission class, 784 SecurityRoleAttribute, 202 see tag

example using, 239

integrated XML documentation, 235

seealso tag

example using, 239

integrated XML documentation, 236 Seek method, Stream class, 292

reading/writing to streams, 293 Select method

ComboBox control, 365 DataTable class, 547 TextBoxBase class, 344 XPathNavigator class, 594

SelectAll method ComboBox control, 365 TextBoxBase class, 345

SelectAncestor method XPathNavigator class, 594

SelectChildren method XPathNavigator class, 594

SelectCommand property DataAdapter classes, 546, 550

SelectDescendants method XPathNavigator class, 594

selected items

ClearSelected method, 359 GetSelected method, 360 SetSelected method, 360

Selected property ToolStrip control, 405

SelectedImageIndex property TreeNode class, 389 TreeView control, 387

SelectedIndex/SelectedIndices properties ListControl class, 359

SelectedItem property ComboBox control, 368

SelectedItems property ListBox control, 359

checking for nullptr, 363

removing items from list using, 364 SelectedNode property

TreeView control, 387 SelectedRtf property

RichTextBox control, 353 SelectedTab property

TabControl control, 395 SelectedText property

TextBoxBase class, 344

SelectedValue property ListControl class, 359

selecting

FullRowSelect property, 380 HoverSelection property, 380 MaxSelectionCount property, 423 ShowSelectionMargin property, 353

selection controls, 358–372 IList interface, 358

list size suggestions, 358 ListControl class, 358

SelectionBullet property RichTextBox control, 353

SelectionColor property RichTextBox control, 353

SelectionEnd property MonthCalendar control, 423

SelectionFont property RichTextBox control, 352, 353

SelectionHangingIndent property RichTextBox control, 353

SelectionIndent property RichTextBox control, 353

SelectionLength property ComboBox control, 365 TextBoxBase class, 344

SelectionMode property ListBox control, 359 SelectionRange property

MonthCalendar control, 423 SelectionRightIndent property

RichTextBox control, 353 SelectionStart property

ComboBox control, 365 MonthCalendar control, 423 TextBoxBase class, 344

SelectionTabs property RichTextBox control, 353

SelectNodes method XmlNode class, 584

SelectSingleNode method XmlNode class, 584

self description assemblies, 8

Semaphore class, 663 semicolon (;) character

ending statements, 29

I N D E X 899

Send method

Socket class, 711, 712 UdpClient class, 719

SendTo method Socket class, 710

separators ToolStripSeparator, 404, 414

Serializable attribute, 738

setting up classes for serialization, 302–304 Serializable transaction isolation levels, 543 serialization

description, 211, 279, 302 managed objects, 302–307 setting up classes for, 302–304

using BinaryFormatter class, 304–306 using SoapFormatter class, 306–307

Serialization class, 216 Serialization namespace, 211, 561 SerializationInfo class, 211 Serialize method

BinaryFormatter class, 305 SerialPort class, 204

service application ServiceBase class, 609 Windows services, 607

service configuration application ServiceInstaller class, 609 ServiceProcessInstaller class, 609 Windows services, 607, 608–609

service control application ServiceController class, 609 Windows services, 607, 608

Service Control Manager (SCM) customizing Windows services, 615 Windows services, 607, 608

Windows services event handling, 613 service processes

see Windows services service providers

Active Directory, 200 ServiceBase class

creating Windows services, 609–621 customizing Windows services, 615 description, 609

properties, 614 Run method, 613

900I N D E X

ServiceController class description, 609

ExecuteCommand method, 628, 629, 630 managing Windows services, 630 methods, 628

properties, 628

Refresh method, 628, 629 ServiceType property, 607 Start method, 628, 629 Status property, 628, 629

ServicedComponent class, 202 ServiceInstaller class

description, 609 properties, 609

Windows services, 621–624 ServiceName property

ServiceBase class, 614 ServiceController class, 628

ServiceProcess namespace, 609 ServiceProcessInstaller class

description, 609 properties, 609

Windows services, 621–624 Services application

custom service control application, 626–630 properties dialog box, 626

Windows services, 625–626 Services namespace, 24, 638

System::Runtime::Remoting, 210 System::Web, 213

ServiceType property ServiceController class, 607

SessionState namespace, 213 Set method

array properties, ref class, 123 indexed properties, ref class, 124 member properties, ref class, 118 NameValueCollection collection, 261

caution: overwriting keys, 262 scalar properties, ref class, 119 static properties, ref class, 121

SET NOCOUNT ON option stored procedures, 526

SetAll method

BitArray collection, 249 SetCompatibleTextRenderingDefault method

Application class, 311

SetCurrentDirectory method Directory class, 281

SetError method ErrorProvider control, 426

SetIconAlignment method ErrorProvider control, 426

SetIconIconPadding method ErrorProvider control, 426

SetItemChecked method CheckedListBox control, 368

SetItemCheckState method CheckedListBox control, 368

SetLastError field DllImportAttribute class, 832

SetLength method Stream class, 292

SetPrincipalPolicy method AppDomain class, 778, 779

SetSelected method ListBox control, 360

SetSocketOption method Socket class, 719

Settings property XmlWriter class, 575

shapes

drawing custom shapes/lines, 492–494 shared assemblies, 7, 746

application configuration files, 754, 755 GAC, 746, 747

adding assemblies to, 747, 748 shared assemblies strong name, 748

No DLL Hell example, 751, 752, 753, 754 resigning assembly, 749

signcoded digital signatures, 749 versioning, 749, 750

getting version number, 751 setting version number, 750

shared resources problem multithreaded programming, 679

SharedProperty class, 202 SharedPropertyGroup class, 202 SharedPropertyGroupManager class, 202 short alias, integer data type, 33 shortcut keys

ShowShortcutKeys property, 415 ShortcutKeys property

ToolStripMenuItem control, 415

Show mode

dialog boxes, 441 ShowDialog mode

dialog boxes, 441 ShowItemToolTips property

ToolStrip control, 405 ShowLines property

TreeView control, 387 ShowPlusMinus property TreeView control, 388 ShowRootLines property TreeView control, 388

ShowSelectionMargin property RichTextBox control, 353

ShowShortcutKeys property ToolStripMenuItem control, 415

ShowToday property MonthCalendar control, 423

ShowTodayCircle property MonthCalendar control, 423

ShowToolTips property TabControl control, 395

ShowWeekNumbers property MonthCalendar control, 423

Shutdown method Socket class, 704, 717

signcoded digital signatures, 749 significance

XmlSignificantWhitespace class, 582 significant digits

loading number with 15+, 37 SignificantWhitespace node type, XML, 564 Simple value

ComboBoxStyle list, 364 SimpleWinService code

autogenerated, 613 converted for safe code, 612 customized, 619

template generated, 611 single buffering, GDI+, 501 Single data type, 35

single line comments, 60 size

AutoScrollMinSize property, 494 AutoSize mode, 420

ClientSize property, 315 ImageSize property, 378

I N D E X 901

Size property Font class, 476 Form class, 315 Image class, 490

PictureBox control, 420 Rectangle/RectangleF structures, 466

Size/SizeF structures, 447, 464–465 brief description, 462

casting Point/PointF to, 465 members, 464

Point/PointF compared, 464 SizeGrip property

StatusStrip control, 410 SizeInPoints property

Font class, 476 SizeMode property

PictureBox control, 420 sizeof operator

ref class drawbacks, 93 Skip method

XmlReader class, 563 Sleep method

Thread class, 666, 669, 675 SmallConfetti enumeration

HatchStyle enumeration, 486 SmallIcon mode

View property, ListView control, 379 SmallImageList property

ListView control, 380

SOAP (Simple Object Access Protocol) accessing Web service using, 647–650 HTTP request SOAP wrapper, 644 HTTP response SOAP wrapper, 644, 645 Web services and, 23

Web services communication protocols, 637 SoapFormatter class, 211

BinaryFormatter class compared, 304 serialization using, 306–307

Socket class

Accept method, 698 BeginAccept method, 721, 722 BeginConnect method, 722 BeginDisconnect method, 723 BeginReceive method, 724 BeginReceiveFrom method, 724 BeginSend method, 724 BeginSendTo method, 724

902 I N D E X

Close method, 704

Connect method, 703, 711, 712 Connected property, 705 Disconnect method, 705 EndAccept method, 722 EndConnect method, 723 EndDisconnect method, 723

GetSocketOption method, 698, 719, 720 Listen method, 697

Receive method, 699, 704, 711, 712 ReceiveFrom method, 708, 719, 720 Send method, 699, 711, 712 SendTo method, 710 SetSocketOption method, 698, 719 Shutdown method, 704, 717

socket helper classes/methods, 712 changing socket options, 719, 720 Tcp Helper class example, 714–717 TcpClient, 713, 714

TcpListener, 712, 713

UdpClient, 717, 719

socket options, changing, 719, 720 SocketException class, 703, 704, 720 SocketOptionName enumeration

MaxConnections value, 698 Sockets namespace, 206, 695 software deployment, 6 software development, 6

using OOP, 87 SolidBrush class, 486 SolidBrushes class, 447 Sort method

Array object, 48 ArrayList collection, 247 ListBox control, 360

Sorted property ListBox control, 359

SortedDictionary<K,V> collection

see also Dictionary<K,V> collection description, 242

namespace, 197 SortedList collection, 251–255

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

ContainsValue method, 253

description, 242

GetByIndex method, 251, 253 GetEnumerator method, 252 Hashtable compared, 251 IndexOfKey method, 253 IndexOfValue method, 253 key/value pairs, 252, 253 Remove method, 252 RemoveAt method, 252

System::Collections namespace, 196 SortKey class, 203

source files, libraries, 145, 147 Source property, Exception class, 169 Specialized namespace, 195, 196, 257 Sphere enumeration

HatchStyle enumeration, 487 SplitContainer control, 398–402

dock property, 398 Orientation property, 398 properties, 398

simple pair of, 402 Splitter control

SplitContainer compared, 398 SplitterDistance property

SplitContainer control, 399 SplitterWidth property

SplitContainer control, 399 Spring property

StatusStrip control, 410 SQL Server

connection strings, 530, 531 managed provider, 526 security, 518

SqlClient namespace, 23, 516, 527 SqlCommand class

CommandText property, 532, 534 CommandType property, 532, 534 ExecuteNonQuery method, 529

Insert/Update/Delete commands, 536 ExecuteReader method, 529

querying database, 532, 534 ExecuteScalar method, 529

returning single value from query, 538 Insert/Update/Delete commands, 536–537 querying database, 532–535

returning single value from query, 538–539 statement execution methods, 529 Transaction property, 543

SqlConnection class Close method, 531

connecting/opening/closing database, 529 constructor, 530

nontransactional database access, 528, 529 Open method, 531

passing data using Web service, 652 SqlDataAdaptor class, 545

see also DataAdapter classes building DataAdaptor, 549–551 creating, 550

deleting rows from data source, 551 inserting rows into data source, 550 populating DataSet, 550

updating rows in data source, 550 SqlDataReader class

Read method, 535 SqlParameters class, 534, 535

stored procedure using parameters, 535 SqlTransaction class

Commit method, 543 Rollback method, 543

using connected ADO.NET with transactions, 543

SqlTypes namespace, 516 Square ref class, 90

instantiating ref class objects, 95 Stack collection, 255–257

description, 242 Clear method, 256 namespace, 196 Peek method, 256 Pop method, 256 Push method, 256

Stack<T> collection, 271–272 namespace, 197

stack instances/objects, 96 StackTrace property

Exception class, 169

standard collection classes, .NET, 241 standard collection interfaces, .NET, 243 Start method

ServiceController class, 628, 629 Thread class, 666, 667

Timer component, 374 start tag

XML document elements, 559

I N D E X 903

Start method TcpListener class, 712

StartCap property Pen class, 482 StartInfo property

Process class, 688 starting

CustomStartCap property, 482 IsStartElement method, 563

OnStart event handler, 613, 615–617, 633 ProcessStartInfo class, 199 SelectionStart property, 344, 365, 423

state

AsyncState property, 723, 725 CheckState property, 330, 415 GetItemCheckState method, 368 PermissionState enumeration, 784 PolicyStatementAttribute class, 785 ReadState property, 563 SessionState namespace, 213 SetItemCheckState method, 368 ThreadState property, 666

ThreadStateException exception, 671, 673 ThreeState property, 330

WindowState property, 315 WriteState property, 575

statements, 29 curly brackets, 29

ending statement, 29 functions, C++/CLI, 28 using statement, 28

StateObject class, 725 static keyword, 100, 121

static member methods, 100 static member variables, 98 static modifier, 53

static properties, 121, 122 static ref class constructors, 103 static variables

multithreaded programming, 680 static_cast operator, 131

status

WaitForStatus method, 628 status bar

see StatusStrip control Status property

ServiceController class, 628, 629

904I N D E X

StatusBar class, 215 StatusStrip control, 410–413

SizeGrip property, 410 Spring property, 410

three panel status bar, 410, 414 StdCall calling convention, 829 StdCall value

CallingConvention enumeration, 831 stdcli::language namespace

declaring arrays, 47 Stop method

ServiceController class, 628 Timer component, 374

stopping

CanStop property, 614, 628

OnStop event handler, 613, 617, 633 stored procedures

building stored procedures, 525–526 default stored procedures code, 525 InsertAuthor stored procedure, 526 SET NOCOUNT ON option, 526 setting parameters, 525

Stream class properties/methods, 292

GetStream method, TcpClient class, 714 StreamReader class

creating from NetStream object, 715 simplifying client, 717

StreamReader class, 204 creating StreamReader, 298 methods, 297, 298

using, 297–299 streams

FileStream class, 292–294 FromStream method, 490 GetStream method, 714 I/O manipulation, 291–297

MemoryStream class, 294–297 reading/writing to streams, 292

StreamWriter class, 204 creating StreamWriter, 298

from NetStream object, 715 methods, 298

simplifying client, 717 using, 297–299

StretchImage mode PictureBox control, 420

Strikeout property Font class, 477

String class, 833 String data type, 41–42 string literals

escape sequences, 59 literals, C++/CLI, 59–60

StringBuilder class marshalling strings, 835

StringCollection collection, 259–260 description, 196, 242

StringDictionary collection, 260–261 description, 196, 242

StringFormat class

DrawString method parameter, 473 properties, 474

namespace, 447 StringReader class, 204 strings

drawing strings, 472–475 downward in rectangle, 474 Font/FontFamily classes, 476 text in rectangle, 472, 473

DrawString method, 449, 454, 472–475 FindString method, 359 FindStringExact method, 359 GetString method, 535, 763 ReadElementString method, 563 ReadString method, 563

ToString method, 41, 56, 57 WriteString method, 575

StringWriter class, 204 strip controls, 402–420

ContextMenuStrip, 414–420 MenuStrip, 414–420 StatusStrip, 410–413 ToolStrip, 404–409 ToolStripContainer, 402–403 ToolStripManager, 403–404 ToolStripMenuItem, 414, 415 ToolStripPanel, 402–403

strong names

shared assemblies, 748 struct types

type casting between, 131 StructLayoutAttribute class

Value property, 836

structs

declaring ref structs, 89 struts

unmanaged classes/struts, 811–815 style

BlinkStyle property, 426 BorderStyle property, 420, 426 ComboBoxStyle list, 364 DisplayStyle property, 405 DropDownStyle options, 364 EnableVisualStyles method, 311 FlatStyle property, 327 GripStyle property, 404 HatchStyle enumerations, 486 HeaderStyle property, 380

VisualStylesEnabled property, 404 Style property

Font class, 477 subscripting

pointer arithmetic and, 48 summary tag

example using, 237

integrated XML documentation, 219, 224 non repeatable tags, 224

SuppressUnmanagedCodeSecurityAttribute, 809 Suspend method

Thread class, 666, 676 Suspended/SuspendRequest states

multithreaded programming, 665 switch statement, 70–71

break statement, 71 switches

command-line switches, 13 synchronization

multithreaded programming, 679–693 Interlocked class, 682–684

Monitor class, 684–687 Mutex class, 687–691 ReaderWriterLock class, 691

ThreadStaticAttribute class, 680–682 using ThreadStatic attribute, 680–682

Synchronized method

generic collection classes, 264 SyncRoot property

generic collection classes, 264 System attribute, files, 286

I N D E X 905

System namespace, 23, 194 Activator class, 736 Attribute class, 739

GC class, 195 Math class, 195 Object class, 194

OperatingSystem class, 195 Random class, 195

String class, 833 Type class, 730 Version class, 195

system pens, GDI+, 483–485 System::Collections namespace, 23, 195, 196

System::Collections::Generic namespace, 23, 195, 196, 197, 264

System::Collections::Specialized namespace, 195, 196, 257

System::Data namespace, 23, 197, 198, 516 System::Data::Common namespace, 516 System::Data::Odbc namespace, 516, 527 System::Data::OleDb namespace, 23, 516, 527 System::Data::Oracle namespace, 516, 527 System::Data::SqlClient namespace, 23, 516, 527 System::Data::SqlTypes namespace, 516 System::Deployment namespace, 198 System::Diagnostics namespace, 24, 198, 199, 687 System::DirectoryServices namespace, 24, 200 System::Drawing namespace, 24, 200, 201, 446

System::Drawing::Drawing2D namespace, 24, 200, 201, 446

System::Drawing::Imaging namespace, 24, 200, 201, 446

System::Drawing::Printing namespace, 24, 200, 201, 446

System::Drawing::Text namespace, 200, 201, 446, 835

System::EnterpriseServices namespace, 201, 202

System::Globalization namespace, 202, 764, 765, 766

System::IO namespace, 24, 203, 750 System::IO::Ports namespace, 204 System::Management namespace, 204, 205 System::Net namespace, 24, 205, 206, 695 System::Net::Sockets namespace, 695

System::Reflection namespace, 24, 206, 207, 729, 730, 735

System::Resources namespace, 24, 207, 208, 757

System::Runtime::InteropServices namespace, 24, 208, 821, 829, 834

906I N D E X

System::Runtime::Remoting namespace, 24, 209, 210

System::Runtime::Serialization namespace, 211 System::Security namespace, 24, 211, 212, 776 System::Security::AccessControl namespace, 776 System::Security::Authentication namespace, 776 System::Security::Cryptography namespace, 776

System::Security::Permissions namespace, 776, 784

System::Security::Policy namespace, 212, 776, 786 System::Security::Principal namespace, 212, 776 System::Text namespace, 200, 201, 446, 835

System::Threading namespace, 24, 212, 662–663, 680–693

System::Web namespace, 24, 213 System::Web::Mail namespace, 24, 213 System::Web::Security namespace, 24, 213, 775 System::Web::Services namespace, 24, 213, 638

System::Web::Services::Configuration namespace, 213, 638

System::Web::Services::Description namespace, 638

System::Web::Services::Discovery namespace, 638

System::Web::Services::Protocols namespace, 638 System::Web::UI namespace, 24, 214 System::Windows::Forms namespace, 24, 214 System::Xml namespace, 24, 215, 216, 561 System:Xml::Schema namespace, 561 System::Xml::Serialization namespace, 211, 561 System::Xml::XPath namespace, 561 System::Xml::Xsl namespace, 561

SystemBrushes class, 447 SystemColors class, 447 SystemException, 169

.NET Framework exception types, 168 order of system exception inheritance, 174

SystemFonts class, 447 SystemIcons class, 447 SystemPens class, 447

T

Tab key

AcceptsTab property, 344, 347 TabControl control, 394–398

properties, 394

simple TabControl, 395 TabPage class, 394 TabPage control, 398

TabCount property TabControl control, 395

tables

Authors table, 519 Content table, 520

creating database tables, 519–520

creating relationships between tables, 520–522

creating table manually in code, 548 DataTable class, 546 DataTableCollection class, 546 getting data from two tables, 522 Hashtable collection, 251–255 integrated XML documentation, 232

Tables and Columns property page, 521 TabPage control, 398

Form compared, 395 properties, 395 TabControl control, 394

TabPages property TabControl control, 395

tabs

AcceptsTab property, 344, 347 SelectedTab property, 395 SelectionTabs property, 353

TargetSite property Exception class, 169

TBStr value

UnmanagedType enumeration, 834 TCP client, 702

closing connection, 704

connecting to server IPEndPoint, 703 disconnecting from socket, 704, 705 example, 703, 704

Tcp Helper class example, 714, 715, 716, 717 Tcp namespace, 210

TCP server

accepting connection, 698

placing connection on own thread, 698 binding socket to IPEndPoint, 697 creating socket, 696

example, 700, 702

receiving messages, 699, 700 sending messages, 698, 699

setting socket to listening mode, 697 TcpClient class, 713

asynchronous functionality, 721 BeginConnect method, 722

closing, 717

Connect method, 713, 714 GetStream method, 714

TcpListener class, 712, 713 AcceptSocket method, 712, 713 AcceptTcpClient method, 713 asynchronous functionality, 721 BeginAcceptSocket method, 721 BeginAcceptTcpClient method, 721 Start method, 712

templates, 156–162

class templates, 158–159 description, 156

function templates, 156–158 generics compared, 163, 164 partial specialization, 159 template parameters, 160–162 template specialization, 159

terms, definition of

integrated XML documentation, 232 ternary operator, 64

text

AppendText method, 288, 344 CommandText property, 532, 534 CreateText method, 288 CreateTextNode method, 584 InnerText property, 583 InputText property, 346 MaskedTextBox control, 345–352 OutputText property, 346 RichTextBox control, 215, 352–358 SelectedText property, 344 ToolStripTextBox, 404, 414 ToolTipText property, 405 XmlText class, 582 XmlTextReader class, 562 XmlTextWriter class, 574

text controls, 343–358 data validation, 352 font styles required, 344

formatted sequence of characters required, 344

TextBoxBase class, 344

Text namespace, 200, 201, 446, 835 Text node type, XML, 564

text nodes

XML document elements, 559

I N D E X 907

Text property ButtonBase class, 327 Label control, 324 ListBox control, 359

MaskedTextBox control, 346 NotifyIcon control, 430 RichTextBox control, 352 TabPage class, 395 TextBoxBase class, 344 ToolStrip control, 405 ToolStripMenuItem control, 415 TreeNode class, 389

TextAlign property Label control, 324 TextBox control, 345

TextBox control, 215, 345 example illustrating, 347 properties, 345

TextBoxBase class, 344 methods/properties, 344

textboxes ToolStripTextBox, 414

TextImageRelation property ToolStrip control, 405

TextInfo class, 203, 765 TextReader class, 204 TextureBrush class, 447, 487–489

clamping, 487 constructor, 487 tiling, 487

tiling using TileFlipXY, 488 using images, 487 WrapMode parameter, 487

WrapModes enumeration, 487 TextWriter class, 204

themes

VisualStylesEnabled property, 404 ThisCall value

CallingConvention enumeration, 831 Thread class, 213, 663

Abort method, 666, 671 constructors, 666

caution: maxStackSize, 667 CurrentPrincipal property, 778, 779, 781 CurrentThread property, 666, 670, 766 Interrupt method, 666, 675 IsBackground property, 665, 666