1. Trang chủ
  2. » Công Nghệ Thông Tin

1750 beginning visual c++ 2010

1,3K 107 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.276
Dung lượng 38,76 MB

Nội dung

Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™ Ivor Horton’s Beginning Visual C++ 2010 ® Ivor Horton www.it-ebooks.info Programmer to Programmer™ Get more out of wrox.com Interact Join the Community Take an active role online by participating in our P2P forums @ p2p.wrox.com Sign up for our free monthly newsletter at newsletter.wrox.com Wrox Online Library Browse Hundreds of our books are available online through Books24x7.com Ready for more Wrox? We have books and e-books available on NET, SQL Server, Java, XML, Visual Basic, C#/ C++, and much more! Wrox Blox Download short informational pieces and code to keep you up to date and out of trouble! Contact Us We always like to get feedback from our readers Have a book idea? Need community support? Let us know by e-mailing wrox-partnerwithus@wrox.com www.it-ebooks.info IVOR HORTON’S BEGINNING VISUAL C++® 2010 INTRODUCTION xxxiii CHAPTER Programming with Visual C++ 2010 CHAPTER Data, Variables, and Calculations 35 CHAPTER Decisions and Loops 121 CHAPTER Arrays, Strings, and Pointers 167 CHAPTER Introducing Structure into Your Programs 251 CHAPTER More about Program Structure 295 CHAPTER Defining Your Own Data Types 353 CHAPTER More on Classes 435 CHAPTER Class Inheritance and Virtual Functions 549 CHAPTER 10 The Standard Template Library 645 CHAPTER 11 Debugging Techniques 755 CHAPTER 12 Windows Programming Concepts 807 CHAPTER 13 Programming for Multiple Cores 843 CHAPTER 14 Windows Programming with the Microsoft Foundation Classes 875 CHAPTER 15 Working with Menus and Toolbars 903 CHAPTER 16 Drawing in a Window 945 CHAPTER 17 Creating the Document and Improving the View 1009 CHAPTER 18 Working with Dialogs and Controls 1059 CHAPTER 19 Storing and Printing Documents 1123 CHAPTER 20 Writing Your Own DLLs 1175 INDEX 1193 www.it-ebooks.info www.it-ebooks.info IVOR HORTON’S BEGINNING Visual C++® 2010 www.it-ebooks.info www.it-ebooks.info IVOR HORTON’S BEGINNING Visual C++® 2010 Ivor Horton www.it-ebooks.info Ivor Horton’s Beginning Visual C++® 2010 Published by Wiley Publishing, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2010 by Ivor Horton Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-50088-0 Manufactured in the United States of America 10 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600 Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose No warranty may be created or extended by sales or promotional materials The advice and strategies contained herein may not be suitable for every situation This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services If professional assistance is required, the services of a competent professional person should be sought Neither the publisher nor the author shall be liable for damages arising herefrom The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002 Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books Library of Congress Control Number: 2010921242 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affi liates, in the United States and other countries, and may not be used without written permission Visual C++ is a registered trademark of Microsoft Corporation in the United States and/or other countries All other trademarks are the property of their respective owners Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book www.it-ebooks.info This book is for Edward Gilbey, who arrived in September 2009 and has been a joy to have around ever since www.it-ebooks.info www.it-ebooks.info operators – Paint( ) event handler operators (continued) overloading, 463–465 : : (scope resolution), 26 [ ] (subscript), 516 binary, 82 bitwise, 82 AND, 82–83 exclusive OR, 85 NOT, 86 OR, 84–85 shift operators, 86–88 comma, 75–76 comparing values, 122 comparison, supporting, 450–454 conditional, 133–135 output, 134–135 decltype, 317–318 delete, 201–203 direct member access, 392 dynamic_cast, 590 function call ( ), 465–466 indirect member selection, 362 logical, 130–133 | | (OR), 131–132 && (AND), 131 ! (NOT), 132 combining, 132–133 new, 201–203 overloading, 446–466, 489–491 >, 452–454 C++/CLI, 533 CString class, 1098 disallowed operators, 447 implementing overloaded operator, 447–450 increment/decrement, 540 operator> function, 447 reference classes, 540–543 value classes, 534–539 safe_cast, 110 scope resolution, 94–96 sizeof, 190–192 static_cast, 590 typeid, 81 unary, 82 options, setting, 27–28 OR (| |) operator, 131–132 organizing code, 508–509 out_of_range exception, 516, 660 output C++/CLI, to command line, 105 to command line, 62–63 conditional operators, 134–135 Debug class, 794–795 controlling, 797–799 destination, 795–796 indenting, 796 device context, 947 formatting, 63–64 left-aligned, 64 free store debugging, 786–793 Trace class, 794–795 controlling, 797–799 destination, 795–796 indenting, 796 Windows GDI, 946 Output( ) function, 579–580 output iterators, 648 output statements, 45 output stream iterators, 720–723 overloading constructors, 378 functions, 310–312 reference types for parameters, 313 when to, 313–314 operators, 489–491 + (addition), 459–463 = (assignment) operator, 454–459 > (greater than) operator, 452–454 C++/CLI, 533 CString class, 1098 disallowed operators, 447 implementing overloaded operator, 447–450 increment/decrement, 540 operator> function, 447 reference classes, 540–543 value classes, 534–539 override keyword, 567 P PadLeft( ) function, 238 PadRight( ) function, 238 page coordinates, mapping mode, 1079 Paint( ) event handler drawing in, 1044 implementing, 1006 1220 www.it-ebooks.info parallel execution/serial execution – PPL (Parallel Patterns Library) parallel execution/serial execution, switching between, 861–862 parallel loop iterations, 845 parallel processing, 843–844 algorithms, 844 parallel_for, 844, 845–846, 866–867 parallel_for_each, 844, 846–849 parallel_invoke, 844, 849, 857–859 example, 850–864 parallel_for algorithm, 844, 845–846 Mandelbrot set, 866–867 terminating operations, 848–849 parallel_for_each algorithm, 844, 846–849 parallel_invoke algorithm, 844, 849 Mandelbrot set, 857–859 parameters const modifier, 270–271 destructors, 436 empty, 254 functions initialization, 302–303 reference parameters, 448 initialization, 269 insert( ) function, 518 multiple, class templates, 483–485 reference lvalue, 470 rvalue, 271–273 applying, 470–472 values, assigning default, 378–380 void keyword, 254 WinMain( ) function, 816 parenthesized substrings, extracting, 348–349 pbuffer pointer, 199 pdata pointer, 194 pen drawing, CLR, 999–1001 Pen object, serialization, 1161–1163 Pen properties, 999–1000 pen styles for drawing, 955 brushes, 957 pen widths, 1070–1071 element creation, 1108–1109 PenDialog( ) function, 1107 pfun( ) function, 296 plotters, Windows GDI, 946 pmessage member, 439, 470 pointers arithmetic, 194–196 array names as, 196–198 arrays and, 194–201 arrays of, 188–190 to char, 186 class objects, 576–578 to classes, 402–403 base classes, 576–578 derived classes, 577–578 to constants, 192–194 declaring, 181–182 dereferencing, 195 to functions, 295–296 as arguments, 299–301 arrays of, 301 declaring, 296–299 incrementing/decrementing, 195 indirection operator, 182 initializing, 183–190, 202 interior, 244–247 lpfnWndProc member, 818 multidimensional arrays and, 200 notation, 200–201 to objects, 401–404 overview, 181 passing arguments by, 262–263 pointer notation, 264–265 pbuffer, 199 pdata, 194 pstart, 246 reasons to use, 183 RECT object, 361 returning from functions, 277–280 struct, 361–362 struct members, 362 this, 390–392 using, 184–186 vector containers, storing, 669–671 PolyLine( ) function, 978–979 polymorphism, 363, 576 in loop body, 606 Pop( ) function, 592, 594, 599 pop-ups, 1026 pop_back( ) function, 661 pop_front( ) function, 671 positioning member function defi nitions, 372 variable declarations, 92 PostSerialization( ) function, 1156 power( ) function, 256 PPL (Parallel Patterns Library), 844 1221 www.it-ebooks.info PPL (Parallel Patterns Library) – queue container PPL (Parallel Patterns Library) (continued) critical_section class, 865 templates, 844 #pragma once directive, 495, 504 precedence of operators, changing, 447 precompiled header fi les, 894 prefi x C, 364 prefi xes in Windows programs, 813–814 PreLoadState( ) function, 1023 preprocessor directives, 43 PreSerialization( ) function, 1157 Print dialog box, displaying, 1147 printArea( ) function, 465, 486 PrintDocument component, 1171 printers, Windows GDI, 946 printf( ) function, 1093 printing aligning text, 1153 cleanup, 1148–1149 device context, 1149–1150 document size, 1145–1146 documents, 1140–1144, 1150–1154 implementing, 1172 multipage, implementing, 1144–1155 paper size, 1144 process of, 1141–1144 sketches, PrintDocument component, 1171 storing print data, 1146–1147 priority queue containers, 689–694 private class members, 382–385 base classes, access, 556–558 private keyword, 382 Product( ) function, 621 product( ) function, 297 program bugs, 757 program fi les, naming, 509 program statements, 44–46 program windows creating, 820–821 initializing, 821–822 specifying, 817–820 programming with strings, 176–177 Windows, 5, 7–9 (See Windows) project folder, 13 projects, 13 console CLR, 24–26 empty, 20–24 defi ning, 14–17 properties, 39 Solution Explorer, 17 source fi les, 39 Win32 console application, 14–17 properties Arrow Keys, 1074 Character Set, 39 classes, 416–429 indexed, 416, 423–428 scalar, 416 DialogResult, 1117 displaying, 39 DisplayStyle, 940 Multline, 1096 Pen, 999–1000 reserved names, 429 scalar defi ning, 416–419 trivial, 419–423 SelectedIndex, 1110 static, 429 toolbar buttons, editing, 925–926 Windows Forms, modifying, 931–932 property keyword, 416 Property Manager tab, 17, 41 protected class members, declaring, 562–564 protected keyword, 562–564 prototypes of functions, 256–259 proverb variable, 162 pstart pointer, 246 PtInRect( ) function, 1026 public keyword, 364, 374 public section, copy constructor, 443 pure virtual functions, 580–581 Push( ) function, 592, 594 push_back( ) function, 517, 653, 660 push_front( ) function, 671 Q query string, 517 queue containers, 685–688 priority containers, 689–694 reference class object storage, 740–744 queue header, 647 queue container, 647 1222 www.it-ebooks.info radio buttons – rvalues R radio buttons CTaskDialog class, 1087–1089 messages, 1069 random access iterators, 649 Random object, 221 randomValues( ) function, 733 rbegin( ) function, 655 Read( ) function, 109–110 reading key presses, 159–160 from stdin, 510 to string objects, 510 ReadKey( ) function, 109–110, 160 ReadLine( ) function, 109–110 ReconstructObject( ) function, 1157 recording document changes, 1131–1133 RECT object, 967 pointers to, 361 RECT structure, 360 Rectangle( ) function, 978–979 rectangles bounding rectangles, 975–977, 1048–1050 drawing CLR, 1001 windows and, 978–979 normalized, 977 RectVisible( ) function, 1012 recursion lambda expressions, 735–736 loops and, 285 using, 288–289 recursive functions, 285–289, 373 ref class keyword, 413 reference class types, 412–415 assignment operator (=), 543–544 copy constructor, 415 derived reference classes, 599–602 overloading operators, 540–543 reference classes destructors, 625–628 fi nalizers, 625–628 reference parameters functions, 448 lvalue, 470 rvalue, 271–273 applying, 470–472 reference types, parameters, overloaded functions, 313 references as arguments to a function, 267–270 to class objects, 404–406 introduction, 206 lvalue declaring, 207–208 initializing, 207–208 members, 355 returning from functions, 280–283 rvalue defi ning, 208 initializing, 208 tracking references, 244 virtual functions, 578–580 RegisterClass( ) function, 820 RegisterClassEx( ) function, 820 reinterpret_cast( ) keyword, 80 ReleaseCapture( ) function, 992 remainders, calculating, 72–73 RemoveAllRadioButtons( ) function, 1088 RemoveElement( ) function, 341 remove_if( ) function, 681 rend( ) function, 655 repeating blocks, loops, 139–142 Replace( ) function, 344 replace( ) function, 519, 725 reserve( ) function, 653, 659 reserved property names, 429 Reset( ) function, 457 ResetScrollSizes( ) function, 1082 resize( ) function, 656 Resource View tab, 17, 1061 RestorePenAndVectorData( ) function, 1164 result variable, 255 return statement, 128, 255–256 reverse-iterators, 1026 rhs, 74 ROP (Raster Operation), 984–985 trails, 1103 Run( ) function, 897 run( ) function, 870 runtime dynamic linking, 1180–1182 RUNTIME_CLASS( ) macro, 896 rvalues, 88–89, 271–273 applying, 470–472 defi ning, 208 initializing, 208 1223 www.it-ebooks.info safe_cast operator – SetRegistryKey( ) function sentence string, 510 S safe_cast operator, 110 SavePenAndVectorData( ) function, 1164 SavePenAttributes( ) function, 1162 SaveSketch( ) function, 1167 SaveSketchCheck( ) function, 1170 scalable mapping modes, 1078–1080 scalar properties, 416 defi ning, 416–419 trivial, 419–423 Scale menu item, 1073 scaling, 1078 scrolling, implementing, 1082–1084 scope automatic variables, 89–92 global, 92 namespaces, 98 resolution, 26 variables, 255 scope resolution operator, 94–96 screen coordinates, pixels, 1079 ScreenToClient( ) function, 1033 scrollbars, 1060 setup, 1083–1084 scrolling, implementing, scaling and, 1082–1084 views in Sketcher, 1016–1021 SDI (Single Document Interface), 876 applications, creating, 882–886 view class, 893–894 searching array elements, 224 null-terminated strings, 213–215 one-dimensional arrays, 224–227 separator characters, 532 strings, 240–243, 523–533 any of a set of characters, 242–243 security, private keyword, 382 SelectClipRgn( ) function, 1154 SelectedIndex property, 1110 SelectObject( ) function, 958 SelectStockObject( ) function, 958 semantic errors, 757 semicolon (;), 44 struct, 354 variable declarations, 50 Send to Back operation, 1052 SendToBack( ) function, 1038–1039 separator characters, searching for, 532 sequence containers (STL), 651–652 STL/CLR library, 737–745 vector containers, creation, 652–655 serial and parallel execution, switching between, 861–862 Serializable attribute, 1155 serialization applying, 1131–1139 binary, 1155–1159 Brush object, 1161–1163 classes Curve, 1163–1164 documents, 1125–1128 element classes, 1135–1139 implementing, 1131 macros, 1129 shape classes, 1136–1139 Sketch, 1160–1161 documents, 1133–1135 CSketcherDoc, 1124–1125 fields, 1155–1156 introduction, 1123–1124 objects, 1158–1159 Pen object, 1161–1163 process, 1129–1130 Sketcher, 1139–1140 sketches, 1160–1171 Serialize( ) function, 1125–1130, 1159 set( ) accessor function, 416 set header fi le, 647 SetCapture( ) function, 992 SetCheck( ) function, 922 SetCompatibleTextRenderingDefault( ) function, 932 SetDefaultRadioButton( ) function, 1088 SetElementTypeButtonState( ) function, 941, 1113 SetIndicators( ) function, 1090–1091 setiosflags( ) function, 523 SetMaxPage( ) function, 1143 SetMinPage( ) function, 1143 SetModifiedFlag( ) function, 1131–1132 SetPixel( ) function, 856 SetRadio( ) function, 922 SetRange( ) function, 1077 SetRegistryKey( ) function, 896 1224 www.it-ebooks.info SetROP2( ) function – societal classes SetROP2( ) function, 984–985 SetScrollSizes( ) function, 1017, 1021, 1083–1084 set container, 647 SetText( ) function, 922, 1093 SetTextAlign( ) function, 1153 SetTextColor( ) function, 1102 setValues( ) function, 733 SetViewportOrg( ) function, 1080 setw( ) function, 64, 144 SetWindowExt( ) function, 1080 SetWindowOrg( ) function, 1152 shape classes, serialization, 1136–1139 shapes, drawing deleting, 1022 moving, 1022 sharing case, 137–139 sharing memory, between variables, 444–446 shift operators, 86–88 short data type, 57 short keyword, 52 ShowDialog( ) function, 1084–1085, 1108, 1172 ShowIt( ) function, 439 showit( ) function, 302 showPerson( ) function, 666 ShowPopupMenu( ) function, 1025 ShowVolume( ) function, 572–573 ShowWindow( ) function, 821–822 signed char data type, 57 signed keyword, 55 size( ) function, 656 size of vector container, 655–660 Size parameter, constant expressions, 485 sizeof operator, 190–192 Sketch class defi ning, 1042–1044 serializable, 1160–1161 Sketcher project CDC class, 950–958 classes for elements, 968 coding menu message functions, 916–920 context menu, 1022–1038 controls, 1060–1061 creating, 897–899 dialogs, 1059–1060 creating resources, 1061–1063 displaying, 1065–1067 exercising, 1072 task dialogs, 1084–1088 DLLs, 1184–1191 drawing mouse and, 965–984 mouse messages, 962–965 edit box controls, 1096–1105 event handlers, 936–937 extending, 909–910 graphics, drawing in practice, 959–960 list boxes, 1093–1096 masked elements, 1038–1039 menu message functions, 915–916 menu messages, 914–915 menu resources, 910–913 message categories, 907–908 message handling, 908–909 message maps, 903–907 mouse messages, capturing, 992–993 OnDraw( ) function, 949–950, 956, 990 pen widths, 1070 printing documents, 1140–1143 multipage printing, 1143–1155 scalable mapping modes, 1078–1080 serialization, 1123–1124 applying, 1131–1138 documents, 1124–1131 shapes deleting, 1022 moving, 1022 sketch document, 1009–1014 sketches, storing, 1009 spin button control, 1072–1078 status bars, 1089–1092 toolbar buttons, 924–928 user interface, message handlers to update, 920–924 views scrolling, 1016–1020 updating multiple, 1014–1016 sketches printing, 1142–1143 PrintDocument component, 1171 recording saved state, 1164–1167 retrieving from fi les, 1169–1170 saving, 1167–1169 serialization, 1160–1171 slashes (/ /), 41 societal classes, 364 1225 www.it-ebooks.info Solution Explorer window – strcpy_s( ) function Solution Explorer window, 11 Class View tab, 17 projects, 17 Property Manager tab, 17 Resource View tab, 17 solutions, building, 18–19 Sort( ) function, 222 sort( ) function, 522, 650, 668–669 sorting arrays associated, 223–224 one-dimensional, 222–224 vector elements, 668–669 words from text, 528–533 source code, Win32, 17–18 source fi les, adding to projects, 39 spaces, removing from strings, 344 spin button controls, 1072–1073 controls tab sequence, 1074 creating, 1073–1074 displaying, 1077–1078 splice( ) function, 680 sqrt( ) function, 980–981 stack containers, 694–697 stack header, 648 stack container, 648 Standard C++ Library, 10 standard library, std, 43 StartsWith( ) function, 240–243 StartTimer( ) function, 860 statement blocks, 47 statements assignment statements, 45 break, 136, 148 continue, 146–148 critical sections, 864–865 goto, 139 if, 123–124, 304 extended, 126–127 nested, 124–128 if-else, 128–130 output, 45 program statements, 44–46 return, 128, 255–256 switch, 135–138 static constructors, 431, 603 controls, 1060 data members, 397–400 function members, 401 global variables, DLLs, 1182 properties, 429 variables, 96, 283–285 static keyword, 429 static_cast keyword, 79 static_cast operator, 590 status bars frames, 1089–1093 Mandelbrot set, 861 panes, 1090–1091 updating, 1091–1093 std, 43 stdin, 510 stdout, 510 stepping over in debugging, 777–780 STL/CLR library, 736 containers, 737 associative containers, 745–752 sequence containers, 737–745 STL (standard template library) algorithms, 649–650 containers, 646–647 array containers, 697–701 associative containers, 701–715 double-ended queue containers, 671–675 headers, 646–647 list containers, 675–685 queue containers, 685–688 range of, 651 sequence containers, 651–652 stack containers, 694–697 function adapters, 650–651 function objects, 650 introduction, 645–646 iterators, 648–649 StopTimer( ) function, 860 storage duration, 89–96 objects class objects in vectors, 663–668 map containers, 703–704 pointers in a vector, 669–671 print data, 1146–1147 scope, 89–96 strcat( ) function, 210, 775 strcmp( ) function, 212–213 strcpy( ) function, 212, 774 strcpy_s( ) function, 212, 439, 553, 774 1226 www.it-ebooks.info stream input data incorrect, debugging – term( ) function stream input data incorrect, debugging, 758 string class, 512 string object creating, 510–512 reading text into, 510 replace( ) function, 519 stdout, 510 strings, 233–234 access, 516–520 appending, 516 blanks, eliminating, 322 characters, for each loop, 161–163 combined, 512 comparing, 239–240, 520–523 concatenation, 512–515 creating, 513–514 empty, reading, 515 handling, character arrays, 174–177 input, character arrays, 175–177 joining, 234–237, 513–514 library functions, 208–215 modifying, 237–239, 516–520 multiple, storing, 179–180 null-terminated comparing, 212–213 copying, 211–212 joining, 210–211 length, 209 searching, 213–215 PadLeft( ) function, 238 PadRight( ) function, 238 programming with, 176–177 query, 517 searching, 240–243, 523–533 sentence, 510 spaces removing, 344 trimming, 237 substrings, 516–517 extracting, 333–336, 348–349 Trim( ) function, 238 TrimEnd( ) function, 238 TrimStart( ) function, 238 strings container class, 646 strlen( ) function, 209, 439 Stroustrup, Bjarne, 364 strspn( ) function, 213–215 strstr( ) function, 214 struct type, 354, 406 C versus C++, 363 defi ning, 354–355 global scope, 358 incrementing, 359 initializing, 355 IntelliSense and, 359–360 members, accessing, 355–359, 362 pointers, 361–362 RECT, 360 semicolon, 354 structures, unions in, 446 subscript ([ ]) operator, 516 substr( ) function, 516, 532 Substring( ) function, 349 substrings, 516–517 extracting, 333–336, 348–349 Sum( ) function, 621 sum( ) function, 276 sumarray( ) function, 301 swap( ) function, 518, 662 swapping, 523 switch statement, 135–138 synonyms for data types, 59 syntactic errors, 757 System namespace, 105 T tab (\t), 64–65 task_group object, 869–873 tasks, 869–873 template keyword, 314, 479 templates class templates, 477–478 combinable, 867–869 defi ning, 478–481 instances, 483 member functions, 479–481 multiple parameters, 483–485 object creation, 481–483 documents, MFC, 878–879 function objects, 486, 723–724 function templates, 314–316 defi ning, 479 lambda expressions, 730–734 PPL, 844 program size and, 316 temporary elements, 971–972 term( ) function, 321, 324 value returned, 325–326, 346–347 1227 www.it-ebooks.info terminology – unions terminology, C++, 365 testing for empty vectors, 656 dialogs, 1063 extended classes, 780–783 key presses, 160 text alignment, 1153 drawing, 1113–1115 fonts, selecting, 1115–1116 rendering, 932 sorting words from, 528–533 text dialog, 1117 text elements CLR Sketcher, 1112–1120 creating, 1101–1102, 1119–1120 defi ning, 1100 text member, 476 TextBox control, 1118–1119 TextElement, 1116–1117 TextOut( ) function, 1103, 1153 this pointer, 390–392 ThisClass class, 618–621 throw exception, C++/CLI, 336 throwing exceptions, 304–306 tilde (~), 436 timer high-resolution, 860 Mandelbrot set, 859 defi ning, 859–860 using, 862–864 _tmain( ) function, 18 Toggle Guides button, 1062 toolbars, 810 adding, 938–942 buttons, 924–928 opening fi les, 1171 properties, editing, 925–926 saving fi les, 1171 tooltips, 927–928 checkmarks, 12 dockable, 12–13 list, 12 options, 12 tooltips, 927–928 ToString( ) function, 237, 410–411, 423, 534 Trace class, 793–803 assertions, 799 output controlling, 797–799 destination, 795–796 generation, 794–795 indenting, 796 using, 800–803 trace output in Windows Forms applications, 803–804 tracepoints, setting, 763 TraceSwitch reference class objects, 797 TraceTest class, 802 tracking handles, creating, 216–217 tracking references, 244 transform( ) function, 726–728 TranslateTransform( ) function, 1040–1041 treble( ) function, 278–279 TriggerEvents( ) function, 622 Trim( ) function, 237–238 TrimEnd( ) function, 238 TrimStart( ) function, 238 truth tables, 82 try block, 307 memory allocation, 309 nested, 306–307 try_lock( ) function, 865–867 two-dimensional arrays, C++, 178 type arguments, 693 explicit, 339 type casting, 78–79 old-style casting, 80–81 type conversion, 71, 78–79 assignments and, 79 explicit type conversion, 71, 79–80 implicit type conversion, 78 typedef keyword, 59 typeid operator, 81 typeinfo header, #include directive, 318 typename keyword, 314–315, 338, 628 U unary minus, 67 unary operators, 82 unconditional branching, 139 unhandled exceptions, 758 Unicode libraries, 21 Unindent( ) function, 796 union keyword, 444–445 UnionRect( ) function, 1146 unions 1228 www.it-ebooks.info unique( ) function – vector containers anonymous, 446 classes and, 446 defi ning, 444–445 members, referencing, 445 structures and, 446 unique( ) function, 680 unlock( ) function, 865–867 unsigned char data type, 57 unsigned int data type, 57 unsigned long data type, 58 unsigned long long data type, 58 unsigned short data type, 57 update handlers, 923–924 UpdateAllViews( ) function, 1014, 1015 UPDATE_COMMAND_UI messages, 914 user-defi ned types, 454 user interface, message handlers and, 920–924 using declarations, 43, 97, 258 using directives, 97 using namespace statement, 26 V value class types, 407–412 operators, overloading, 534–539 values boxing/unboxing, 594–595 comparing, 121–123 converting type, 71 lvalues, 88–89, 470 declaring, 207–208 initializing, 207–208 named objects, 472–477 members, incrementing, 355–356 parameters, assigning default, 378–380 passing by to functions, 260–261 returning from functions, pointers, 277–280 rvalues, 88–89, 271–273 applying, 470–472 defi ning, 208 initializing, 208 term( ) function, 325–326, 346–347 variables assigning new, 45 changing, 767 initializing, 51–52 specific sets, 59–61 values vector, 654 variables addresses, 182 automatic, 89–92 bool, 523 Boolean, 56 capturing specific (lambda expressions), 730 const, 70 count, 533 data exchange, 1076 declaring, 44–45, 50–51 positioning declarations, 92 double, 326 dval, 445 fundamental data types, 363 global, 92–96 static, DLLs, 1182 incrementing, 73 index, 325 initializing, 51–52 hexadecimal constants, 54 new operator, 202 integer, 52–53 MAX, 330 memory, sharing, 444–446 modifying, 73–74 naming, 49–50 newline, 66 proverb, 162 result, 255 scope, 255 static, 96, 283–285 values assigning new, 45 changing, 767 debugging and, 765–766 specific sets, 59–61 viewing in Edit window, 767 vbx extension (Visual Basic Extension), 1179 vector containers capacity, 655–660 class objects, storing, 663–668 creating, 652–655 elements accessing, 660–661 inserting/deleting, 661–663 sorting, 668–669 empty, testing for, 656 1229 www.it-ebooks.info vector containers – Windows vector containers (continued) handle storage, 737–740 pointers, storing, 669–671 size, 655–660 sizing, 656 vector header fi le, 646 vectors, values, 654 vector container, 646 versions of C++, Viewport Extent parameter, 1079 Viewport Origin parameter, 1079 views MFC, 877 Sketcher scrolling, 1016–1021 updating, 1014–1016 virtual destructors, 586–590 virtual functions, 572–576 calling, 576 pure virtual functions, 580–581 references, 578–580 virtual keyword, 574–576 virtual machine, visibility specifiers for classes and interfaces, 606–607 void keyword, 254 Volume( ) function, 371, 452, 574 volume debugging, 770 VOLUMEDEBUG, 770 W wait( ) function, 870 wchar_t data type, 54, 57 wcslen( ) function, 209 what( ) function, 309 where keyword, 338 while loop, 150–152, 307, 322 whitespace, 46–47 wide character type, 54 Win32 console application, 14–17 debugging application, 19–20 executing program, 20 source code, 17–18 Win32 Application Wizard dialog box, 15 Win32 Debug, 760 Window Extent parameter, 1079 Window Origin parameter, 1079 WindowProc( ) function, 811, 814, 828, 829 complete function, 831–832 switch statement, 829 Windows applications creating MFC application, 28–30 MFC classes, 879–880 operating system and, 810 data types, 812–813 forms, 840–841 GDI (Graphical Device Interface), 946–948 mapping modes, 947–948 messages, 811, 822–826, 907 client area, drawing, 829–831 decoding, 829 functions, 827–832 message loop, 822–824 multitasking, 824–826 non-queued, 822 queued, 822 programming, 5, 7–9 event-driven programs, 811 notation, 813–814 overview, 808 prefi xes, 813–814 program organization, 834–835 program structure, 814–833 program window creation, 820–821 program window initialization, 821–822 program window specification, 817–820 sample program, 833 windows, 808–810 borders, 809 client area, 809, 946 close button, 809 DestroyWindow( ) function, 1067 docking, 11 drawing in, 945–946 client area, 967–968 Editor window, 11 elements, 809 floating, 11 maximize button, 809 MDI child window, 809 MDI parent window, 809 minimize button, 809 program window 1230 www.it-ebooks.info Windows API – wstring object creating, 820–821 initializing, 821–822 specifying, 817–820 Solution Explorer, 11 title bar, 809 toolbar, 810 unlocking from position, 11 Windows API, 808, 811–812 BeginPaint( ) function, 830 CreateWindow( ) function, 820 GetClientRect( ), 830 RegisterClass( ) function, 820 RegisterClassEx( ) function, 820 Windows Forms applications C++/CLI, 929–932 creating, 31–32 GUI, 808 trace output, 803–804 C++/CLI, 928–929 properties, modifying, 931–932 WinMain( ) function, 814–827 arguments, 816 complete function, 826–827 messages, 822–826 functions, 827–832 parameters, 816 program windows creating, 820–821 initializing, 821–822 specifying, 817–820 WindowProc( ) function, 828 Wizards Add Member Function, 497–498 Add Member Variable Wizard, 1074–1075 Application Wizards, 812 Class Wizard, 904, 970–971, 1063–1064 Event Handler, 915–916 MFC Class Wizard, 1091 wmain( ) function, 48 WM_CONTEXTMENU message, 1024 WM_LBUTTONDOWN message, 963 WM_LBUTTONUP message, 963 WM_LBUTTONUP message, 990 WM_MOUSEMOVE message, 963, 1033–1035 WM_PAINT message, 945–946 WNDCLASSEX, 817–818 WndProc( ) function, 811 WORD data type, 813 words, sorting from text, 528–533 words array, 531 wrapping lambda expressions, 734–736 Write( ) function, 105, 343, 794 WriteIf( ) function, 794 WriteLine( ) function, 105, 411, 535, 794 WriteLineIf( ) function, 794 writing C++ applications, 3–4 wstring object, 511 1231 www.it-ebooks.info www.it-ebooks.info Related Wrox Books Beginning ASP.NET 4: in C# and VB ISBN: 978-0-470-50221-1 This introductory book offers helpful examples in a step-by-step format and has code examples written in both C# and Visual Basic With this book, a web site example takes you through the processes of building basic ASP.NET web pages, adding features with pre-built server controls, designing consistent pages, displaying data, and more Beginning Visual C# 2010 ISBN: 978-0-470-50226-6 Using this book, you will first cover the fundamentals such as variables, flow control, and object-oriented programming and gradually build your skills for web and Windows programming, Windows forms, and data access Step-by-step directions walk you through processes and invite you to “Try it Out” at every stage By the end, you’ll be able to write useful programming code following the steps you’ve learned in this thorough, practical book If you’ve always wanted to master Visual C# programming, this book is the perfect one-stop resource Professional ASP.NET 4: in C# and VB ISBN: 978-0-470-50220-4 Written by three highly recognized and regarded ASP.NET experts, this book provides all-encompassing coverage on ASP.NET and offers a unique approach of featuring examples in both C# and VB After a fast-paced refresher on essentials such as server controls, the book delves into expert coverage of all the latest capabilities of ASP.NET You’ll learn site navigation, personalization, membership, role management, security, and more Professional C++ ISBN: 978-0-7645-7484-9 This code-intensive, practical guide teaches all facets of C++ development, including effective application design, testing, and debugging You’ll learn simple, powerful techniques used by C++ professionals, little-known features that will make your life easier, and reusable coding patterns that will bring your basic C++ skills to the professional level Professional C# and NET ISBN: 978-0-470-50225-9 After a quick refresher on C# basics, the author dream team moves on to provide you with details of language and framework features including LINQ, LINQ to SQL, LINQ to XML, WCF, WPF, Workflow, and Generics Coverage also spans ASP.NET programming with C#, working in Visual Studio 2010 with C#, and more With this book, you’ll quickly get up to date on all the newest capabilities of C# Professional Visual Basic 2010 and NET ISBN: 978-0-470-50224-2 If you’ve already covered the basics and want to dive deep into VB and NET topics that professional programmers use most, this is your guide You’ll explore all the new features of Visual Basic 2010 as well as all the essential functions that you need, including NET features such as LINQ to SQL, LINQ to XML, WCF, and more Plus, you’ll examine exception handling and debugging, Visual Studio features, and ASP.NET web programming Professional Visual Studio 2010 ISBN: 978-0-470-54865-3 Written by an author team of veteran programmers and developers, this book gets you quickly up to speed on what you can expect from Visual Studio 2010 Packed with helpful examples, this comprehensive guide examines the features of Visual Studio 2010 and walks you through every facet of the Integrated Development Environment (IDE), from common tasks and functions to its powerful tools Visual Basic 2010 Programmer’s Reference ISBN: 978-0-470-49983-2 Visual Basic 2010 Programmer’s Reference is a language tutorial and a reference guide to the 2010 release of Visual Basic The tutorial provides basic material suitable for beginners but also includes in-depth content for more advanced developers www.it-ebooks.info Build real-world applications as you dive into C++ development By following author Ivor Horton’s accessible tutorial approach and detailed examples you can quickly become an effective C++ programmer Thoroughly updated for the 2010 release, this book introduces you to the latest development environment and teaches you how to build real-world applications using Visual C++ With this book by your side, you are well on your way to writing applications in both versions of C++ and becoming a successful C++ programmer wrox.com Ivor Horton’s Beginning Visual C++ 2010: • Teaches the essentials of C++ programming using both of the C++ language technologies supported by Visual C++ 2010 • Shares techniques for finding errors in C++ programs and explains general debugging principles • Discusses the structure and essential elements that are present in every Windows® application • Demonstrates how to develop native Windows applications using the Microsoft Foundation Classes • Guides you through designing and creating substantial Windows applications in both C++ and C++/CLI • Features numerous working examples and exercises that help build programming skills Ivor Horton is one of the preeminent authors of tutorials on the Java, C and C++ programming languages He is widely known for his unique tutorial style, which is readily accessible to both novice and experienced programmers Horton is also a systems consultant in private practice He previously taught programming for more than 25 years Wrox Beginning guides are crafted to make learning programming languages and technologies easier than you think, providing a structured, tutorial format that will guide you through all the techniques involved $54.99 USA $65.99 CAN www.it-ebooks.info Programming / C++ Development Programmer Forums Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world Code Downloads Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use Read More Find articles, ebooks, sample chapters, and tables of contents for hundreds of books, and more reference resources on programming topics that matter to you ... HORTON’S BEGINNING Visual C++ 2010 www.it-ebooks.info www.it-ebooks.info IVOR HORTON’S BEGINNING Visual C++ 2010 Ivor Horton www.it-ebooks.info Ivor Horton’s Beginning Visual C++ 2010 Published... www.it-ebooks.info IVOR HORTON’S BEGINNING VISUAL C++ 2010 INTRODUCTION xxxiii CHAPTER Programming with Visual C++ 2010 ... CHAPTER 1: PROGRAMMING WITH VISUAL C++ 2010 The NET Framework The Common Language Runtime Writing C++ Applications Learning Windows Programming 2 Learning C++ The C++ Standards Attributes Console

Ngày đăng: 06/03/2019, 11:30

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN