975 ivor hortons beginning visual c++ 2012

988 714 0
975 ivor hortons beginning visual c++ 2012

Đ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

www.it-ebooks.info www.it-ebooks.info ffirs.indd ii 17/09/12 6:32 PM IVOR HORTON’S BEGINNING VISUAL C ++® 2012 INTRODUCTION xxxv CHAPTER Programming with Visual C++ CHAPTER Data, Variables, and Calculations 25 CHAPTER Decisions and Loops 97 CHAPTER Arrays, Strings, and Pointers 135 CHAPTER Introducing Structure into Your Programs 189 CHAPTER More about Program Structure 231 CHAPTER Defining Your Own Data Types 277 CHAPTER More on Classes 333 CHAPTER Class Inheritance and Virtual Functions 441 CHAPTER 10 The Standard Template Library 491 CHAPTER 11 Windows Programming Concepts 601 CHAPTER 12 Windows Programming with the Microsoft Foundation Classes (MFC) 635 CHAPTER 13 Working with Menus and Toolbars 659 CHAPTER 14 Drawing in a Window 685 CHAPTER 15 Improving the View 739 CHAPTER 16 Working with Dialogs and Controls 769 CHAPTER 17 Storing and Printing Documents 815 CHAPTER 18 Programming Windows Apps 849 INDEX 905 www.it-ebooks.info ffirs.indd i 17/09/12 6:32 PM www.it-ebooks.info ffirs.indd ii 17/09/12 6:32 PM IVOR HORTON’S BEGINNING ® Visual C ++ 2012 www.it-ebooks.info ffirs.indd iii 17/09/12 6:32 PM www.it-ebooks.info ffirs.indd iv 17/09/12 6:32 PM IVOR HORTON’S BEGINNING ® Visual C++ 2012 Ivor Horton John Wiley & Sons, Inc www.it-ebooks.info ffirs.indd v 17/09/12 6:32 PM Ivor Horton’s Beginning Visual C++® 2012 Published by John Wiley & Sons, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2012 by Ivor Horton Published by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-118-36808-4 ISBN: 978-1-118-43941-8 (ebk) ISBN: 978-1-118-41703-4 (ebk) ISBN: 978-1-118-43431-4 (ebk) 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 publishes in a variety of print and electronic formats and by print-on-demand Some material included with standard print versions of this book may not be included in e-books or in print-on-demand If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com For more information about Wiley products, visit www.wiley.com Library of Congress Control Number: 2012946046 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 All other trademarks are the property of their respective owners John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book www.it-ebooks.info ffirs.indd vi 17/09/12 6:32 PM This book is for my dear wife, Eve, who for so many years has given me unconditional support and love in whatever I choose to I could not have written this without her www.it-ebooks.info ffirs.indd vii 17/09/12 6:32 PM www.it-ebooks.info ffirs.indd viii 17/09/12 6:32 PM randomValues( ) function template, lambda expressions and – Resource View tab randomValues() function template, lambda expressions and, 598 range-based for loops, 129 iterating characters in strings with, 424 references, using in, 181–182 Raster OPeration (ROP) drawing mode and, 731 trails and, 814 raw pointers, 504 ReadMe.txt fi le, 12 recording document changes, 829–831 RECT objects, 289 RECT structure, 289 rectangles CRectangle constructor, 788 drawing, 707–708, 725, 739 enclosing, creating, 722–725 enclosing, for lines, 723 normalized, 723 Recursion in Lambda Expressions (example), 600–602 recursive functions analyzing arithmetic expressions and, 267 basics of, 228–231 redrawing windows, 616 ref class class types variables (C++/CX), 861 defi ned, 857 object members, accessing, 861 ref class keyword, 858 ref struct types, 857 reference cycles, 502 reference documentation for WinRT namespaces, 856 reference types, function overload selection and, 254 references as arguments to functions, 210–212 basics of, 180 to class objects, 329, 332–334 defi ned, 212 lvalue, declaring and initializing, 180–181 vs pointers, 212 return types, 223–226 rvalue, 182 using in rage-based for loops, 181–182 using with virtual functions, 476–477 referencing members of structs (example), 284–287 regions, clip rectangles and, 852 RegisterClassEx() API function, 617, 618 registering windows classes, 617 registry key (MFC), 658 reinterpret_cast(), 66–69 relational operators, 97 ReleaseCapture() function, 739 releasing programs, 15 Release versions, 31 remainders, calculating, 61 remove() function (lists), 542 remove_if() function (lists), 544 removing toolbar buttons, replace() algorithm, 588–589 replace() function replacing parts of strings with, 427–428 using with pointers, 589 reserve() function, vector containers and, 509, 515 resize() function numbers of elements in lists and, 537 vector containers and, 512 resizing windows, 607, 636 Resource Editor creating MFC applications and, 644 pane, 672, 779, 781–782, 793 resource files basics of, 608 menus and, 671 resource string tables, creating status bar panes and, 804–805 Resource View tab MFC, 651 Windows programming, 13 932 www.it-ebooks.info bindex.indd 932 17/09/12 10:44 AM resources – sequence containers resources console programs and, 13 creating and modifying, 644 defi ned, 671 dialog resources, creating, 776–779 edit box resources, creating, 809–810 menu resources, creating and editing, 671–674 for XAML templates, 883 rethrowing exceptions, 248 return statements, functions and, 197–198 return types of functions, 196 return values of functions, 196 returning references from functions, 223–226 reverse iterators, 511 ribbons (windows), 608 RichTextBlock element, 875–876, 898, 899–900 rollLength const variable, 58 RotateTransform element, 904 rubber-banding, 706 Run() function (MFC), 659 rvalue references basics of, 180, 182 function overload selection and, 254 lvalue references and, 216 passing values to functions and, 212 reference parameters, 214–216, 371, 374–376 rvalues basics of, 76–77 named objects as, 376–379 S scaling document size, setting, 799 mapping modes, setting, 799–801 scalable mapping modes, 797–799 scale menu items, adding, 791 scrolling with, 801–803 UI elements, 901–903 SCARY iterators, 501 schema numbers, 827 scope basics of, 77–78 declared within functions, 197 scope resolution operator (::), 33, 82, 197 screen coordinates, 797 scrolling with scaling, 801–803 scrollbars, 802–803 scrolling views client coordinates, 751–753 coordinate systems, 750–751 getting started, 748–749 sdf extension, 12 SDI (Single Document Interface), 640 See also MFC Application Wizard output SDI applications command message processing and, 670 creating, 645–649 See also MFC Application Wizard output searching algorithms and, 589 for library files, 33 for message handlers, 667 namespaces, 84 null-terminated strings, 187–189 strings, 432–436, 440 SelectObject() function using brushes and, 705 using pens and, 703 semicolons (;) assignment statements and, 55 declarations and, 41, 153 else keywords and, 104 function prototypes and, 199 if statements and, 99 for loops and, 119 macros and, 827 sequence containers See also vector containers array containers, 530–533 basics of, 506–508 double-ended queue containers, 533–536 933 www.it-ebooks.info bindex.indd 933 17/09/12 10:44 AM sequence containers (continued) – sln extension sequence containers (continued) forward_list container templates, 548–550 list containers See list containers priority queue containers basics, 553–554 Priority Queue Containers, Using (example), 554–559 queue containers, 550–553 stack containers, 559–561 serialization basics of, 720, 821–822, 827–828 basics of applying, 829 document changes, recording, 829–831 in document class defi nition, 822–823 in document class implementation, 823–826 documents, serializing, 831–833 element classes, serializing, 833–837 exercising, 837–839 functionality of CObject-based classes, 826–827 implementing for classes, 829 Serialize() Function, 824 set container, 565 SetCheck() function, 683–684 SetModifiedFlag() function, 829–830 SetRegistryKey() function (MFC), 658 sets (containers), 506 SetScrollSizes() function, 748–749, 753 setValues() function template, lambda expressions and, 597–598 SetViewportOrg() member, 695 shape events, handling, 896–898 Shape_Tapped() handler (MemoryTest project), 881, 882 shared_ptr objects, 503–504 shared_ptr type, 501–502 shift operators (bitwise), 74–76 short keyword, 43 shortcut menus See context menus shortcuts for creating game cards, 882 menus and, 670, 672, 674, 755 for viewing h files, 668 Show_How_Tapped() handler (MemoryTest project), 899, 900 showit() function, 242–243 ShowVolume() function, 483 signatures, overloaded functions and, 252 signed keyword, 45 Simulator Debugger, 882–883 Single Document Interface (SDI) See SDI (Single Document Interface) size document size, setting, 799 of documents and printing, 842, 843, 844 of Grid element, 901 paper size, printing and, 843 width and length when printing, 845–847, 849–850 of windows, 607, 618, 636 size() function, containers and, 550, 554, 559, 571 size_t type, 163, 183 sizeof operator operator overloading and, 350 pointers and, 163–165 in Your First Use of Classes (example), 298 Sketcher program adding menus, 670–671 classes, 666–667 controls and See controls creating, 659–661 dialogs and See dialogs drawing and See drawing in windows printing and See printing serialization and See serialization views and See views, improving sketches, drawing, 737–740 slashes (//) comments and, 31 start and end tags and, 864 sln extension, solutions and, 10 934 www.it-ebooks.info bindex.indd 934 17/09/12 10:44 AM smart pointers – static_pointer_cast smart pointers basics of, 176, 501–504 casting, 504 memory leaks and, 223 raw pointers, 504 shared_ptr object, 503–504 unique_ptr object, 502–503 using, 504 SolidColorBrush objects, 861 Solution Explorer pane, new Windows apps and, 855, 871–872 tab (MFC), 651 tab (Windows programming), 12 window, solutions, building (example), 14 sort() algorithm, 505 sort() function, comparing strings and, 430, 431 sort() function template arrays and, 525 vectors and, 525–526 sorting list elements, 539 Sorting Words from Text (example), 436–441 source code, modifying (example), 13–14 spaces, eliminating from strings, 264 spin button controls basics of, 777, 791 CScaleDialog class and, 793–796 scale menu items, adding and, 791 spin buttons, creating, 792–793 spin buttons, displaying, 796–797 toolbar buttons, adding, 791 splice() function (lists), 543 square brackets ( [ ] ) deleting arrays and, 176, 179 function pointer array elements and, 241 as subscript operator, 424 squares, creating, 879–880 stack containers, 559–561 stacks, 78 Standard C++ Library, Standard Template Library algorithms, 504–505, 588–591 associative containers See associative containers basics of, 495–496 components, listed, 496 containers See containers; sequence containers function adapters, 506 function objects in, 505–506, 586–588 iterators See iterators lambda expressions See lambda expressions smart pointers, 501–504 static assertions, 591–592 storing tuples in arrays (example), 563–565 tuple class templates basic, 561–562 type traits, 591–592 Start button (MemoryTest project), 899 start tags (XAML), 863 startup transitions (applications), 903 stateless lambdas, 593, 599 statements assignment statements basics, 35 output statements, 35–36 program statements, 34–36 repeating blocks of See loops statement blocks, 37 static assertions, STL and, 591–592 static members of classes static data members, 326, 329 static function members, 329 static resolution, 470 static storage duration, 81, 84 static variables basics of, 84, 226 in functions, 226–228 static_cast keyword, 68 static_cast operator, 202 static_cast(), 68 static_pointer_cast, 504 935 www.it-ebooks.info bindex.indd 935 17/09/12 10:44 AM status bars, adding to frames – structure, of Windows programs status bars, adding to frames basics of, 803–804 status bar frames, creating, 804–806 status bars, updating, 806–807 std, namespaces and, 90 stdafx.h fi les compilation of fi les and, 16 header fi les, in console programs, 38, 39 modifying source code and, 13–14 std::begin() and std::end() functions, 501 stdcall, 613 std::cout, 14, 90 std::endl, 18 std::forward() function, 393 std::move() function, 381 std::move() library function, 216 std::shared_ptr smart pointer, 718 std::string, 448 storage duration automatic, 78 static, 81, 84 storing class objects in vectors, 520–526 integer values, 45 Multiple Strings, Storing (example), 152–154 objects, map containers and, 566–568 Person objects in vectors, 524, 525 pointers in vectors, 527–529 print data, 844–845 std::string for, 448 tuples in arrays (example), 563–565 storyboard animations transitions, 904–906 strcat() functions, 183–185 strcmp() function, 186–187 strcpy() function, 185–186 strcpy_s() function , 185–186, 449 stream iterators, 579 streams, 35 string class basics of, 183 Perfect Forwarding example and, 393–396 string objects, 394 strings See also library functions for strings; null-terminated strings character arrays and, 147–150 constructors and, 341 eliminating blanks from, 264 eliminating spaces from, 264 length of, 261 pointer notation and, 171–172 std::string for storing, 448 Storing Multiple Strings (example), 152–154 strings, library classes for, 418–441 accessing and modifying, 424–428 comparing, 428–432 concatenating, 420–423 searching, 432–436 Sorting Words from Text (example), 436–441 string objects, creating, 418–420 strings of characters, 44 strlen() function destructors and, 341, 342 string length and, 183 Stroustrup, Bjarne, 147, 293 strspn() function, 187–188 struct keyword, 282, 292 structs basics of, 282 vs classes, 295 classes and, 292 defi ning, 282–283 initializing, 283 IntelliSense and, 287–288 members, accessing, 283 RECT structure, 289 referencing members (example), 284–287 using pointers with, 289–291 structure, of Windows programs See also WinMain() function vs typical console programs, 936 www.it-ebooks.info bindex.indd 936 17/09/12 10:44 AM structure of C++ programs – TrackPopupMenu( ) function structure of C++ programs See C++ program structure structures See also structs vs classes, 292 defi ned, 282 unions in, 349 style members of struct, 615–617 subscript operator ([ ]), 423 substr() function, extracting characters from text and, 440 substrings, extracting, 275–277 subtraction operator (CBox class), 400 sumarray() function, 241 suo extension, solutions and, 10 swap() function strings and, 431 vectors and, 519–520 swap() member function, interchanging strings and, 427 switch statements for comparing numeric values, 111–114 decoding Windows messages and, 626–627 synonyms, defi ning for data types, 49–50 system menus (windows), 607–608 T tab sequence (controls), 792–793 tag names, 347 tags (XAML), 863 template keyword, 255, 384 templates See also class templates document templates (MFC), 641–643 function object templates, 587, 588 for function objects, 392 function templates, 198, 255–258 inserter templates, iterators and, 579 instances of, 382 instantiation and, 385 lambda expressions and, 595 for operator functions, 355 type testing templates, 592 term() function, 263, 266, 267–268 terminology, classes, 294 terms defi ned, 263 value of, 267 ternary operators, for comparing numeric values, 109–110 text Text, Sorting Words from (example), 436–441 text elements, creating, 813–815 text elements, defi ning, 812 Text menu item, adding, 811–812 TextEditor project folder (MFC), 649–650 this pointer, 318–321 throw keyword, 244, 245, 249 throw statements, 245–246 throwing exceptions, 244–246 time, constant and linear, 517 titles creating (MemoryTest project), 874–876 title bar icons (windows), 607 title bars (windows), 607 _tmain() function, 14, 18 toolbar (windows), 608 toolbar buttons adding, 8, 684–687, 791 defi ned, 685 removing, tooltips, adding, 688 toolbars dockable (IDE), 9–10 options (IDE), 8–9 options (MFC applications), 648 Toolbox pane, 865–866, 867, 869 tooltips adding, 688 basics of, top() function, containers and, 559 TrackPopupMenu() function, 756–757 937 www.it-ebooks.info bindex.indd 937 17/09/12 10:44 AM trailing return types – variables trailing return types, 198, 259, 260 trails moving geometric elements and, 816 moving text elements and, 816–817 transform() algorithm, 590 transform()function, 592 transitions, 903–906 tree controls, 777 triangles, design of game cards and, 880 trivial properties, 858 TRUE value, numeric type variables and, 46 truth tables, 71 try blocks exceptions and, 245–246 memory allocation and, 250 nested, 247–248 try keyword, 244, 249 tuple class templates basics of, 561–562 tuples, storing in arrays (example), 563–565 type arguments, using containers and, 496, 557–558, 559 type conversion, 59, 66–69 type modifiers, 58 type of variables, 35 type parameters, function templates and, 255 type testing templates, 592 type traits, STL and, 591–592 typedef keyword, synonyms for data types and, 49–50 typedef statements, tuples and, 562, 564–565 typeid operator, 70 typename keyword, 256 type-safe enumerations, 87–88 U unary minuses, 56 unary predicates, 506 underscore (_), variable names and, 39 Unicode libraries, 16 union keyword, 347 unions anonymous, 348–349 in classes and structures, 349 defi ned, 347 defi ning, 347–348 unique() function (lists), 542–543 unique_ptr objects, 502–503 unique_ptr type, 501 unsigned keyword, 46 update region, 691 UPDATE_COMMAND_UI, 682 UpdateAllViews() function, 746–747, 767–768, 770 UpdateWindow() function, 619 user interfaces (UIs) defining (MemoryTest project), 872–874 for drawing sketches, 739 event handling for UI elements (XAML), 870–871 GUI, vs operation (Windows apps), 855 options (MFC applications), 647 UI elements in XAML, 865–868 Windows programs, 606–608 using declarations, namespaces and, 33–34, 90–91 using directives, defi ned, 90 Using Manipulators (example), 52–53 V va_arg macro, 218 validation dialog data validation, 795 of pointer values, 657 value types (WinRT), 857 variables automatic, 78–80 in body of functions, 197 data types and, 42 declaring, 41 defi ned, 35, 39, 70 defi ning, 39–40 938 www.it-ebooks.info bindex.indd 938 17/09/12 10:44 AM vector containersr – weak_ptr type dynamic memory allocation and, 174 globals, 30, 80–84 increment operators and, 63 initial values for, 41–42 integer, 42–44 modifying in arithmetic operations, 61–62 naming, 39–40 of ref class types (C++/CX), 861 scope and, 77–78 sharing memory between, 346–349 specific, capturing (lambda expressions), 594–595 static variables basics, 84 static variables in functions, 226–228 storage duration and, 77–78 variable declarations, 35, 41, 80 variable defi nition, 41 vector containers accessing elements in, 516–517 capacity vs size of, 511–516 creating, 508–511 vs double-ended queue containers, 534 inserting and deleting elements in, 517–520 sorting elements of, 526–527 storing class objects in, 520–526 storing pointers in, 527–529 vector template, 506–508 vector container, 728 VerticalAlignment property (MemoryTest project), 877, 880 view class menus, associating with, 756–757 MFC, 656–657 views basics of, 640–641 linking to documents, 641–643 views, improving context menus and See context menus elements, moving and deleting, 754 elements in, creating, 789–790 masked elements, 771–772 MM_LOENGLISH mapping mode, 753 mouse cursor and See elements under cursors, identifying scrolling views See scrolling views updating, 746–748, 767 virtual destructors, 483–486 virtual Draw() function, 719 virtual functions abstract classes and, 478–481 adding to classes, 300 basics of, 468–470 correct operation of, 473 defi ned, 471–473 function overriding, preventing, 473–474 indirect base classes and, 481–483 pointers to class objects, 474–476 pure, 477–478 references, using with, 476–477 Using an Inherited Function (example), 470–471 virtual destructors, 483–486 virtual keyword, 471, 472, 485 Visibility property, 871, 888–889, 896 Volume() function CBox class defi nition and, 299–300, 313 CCan class and, 480 CCandyBox class, 451–454 CContainer class, 477–478 function overriding and, 474–475 inherited functions and, 470–471 member function const and, 322–323 operator overloading and, 354–355 protected class members and, 458–460 virtual functions and, 471–473, 477–478 W wchar_t variables, 44 wcslen() function, 183 weak_ptr type, 502 939 www.it-ebooks.info bindex.indd 939 17/09/12 10:44 AM Web sites for further information – Windows programming Web sites for further information Bjarne Stroustrup, 147 constant values for style, 615 constants specifying windows displays, 614 MSDN library, 614, 615 reference documentation, 856 while loops arrays, using and, 143 basics of, 126–128 comparing strings and, 430–431 whitespace, 37 wide character types, 44 width of documents when printing, 845–847, 849–850 of lines, 702 m_PenWidth, 783–785 OnPenWidth() handler, 786 pen widths, 777–778, 781, 786–789 Win32 basics of, 2, 606 See also Windows programming Project for Win32 Console Application, Creating (example), 11–13 Win32 Application Wizard, 11, 13 window class, Windows programming and, 633–634 WindowProc() function basics of, 609, 612, 626 complete, 629–630 messages and, 620, 625–626 vs WinMain() function, 612 Windows apps basics of, 854 C++/CX See C++/CX developing, 855 environment for use of, 854 operation of vs UI of, 855 vs Windows desktop apps, 854 WinRT, 854, 856–857 Windows apps, programming (example) application files, 871–872 application startup transitions, 903 card back events, handling, 894–896 Card class, defi ning, 884–885 card pack, initializing, 888 cards, shuffling, 893 child elements of cardGrid, 888–890 game, initializing, 890–892 game cards See game cards game control button events, handling, 899–901 game controls, adding, 876–878 game operations, implementing, 883–887 MainPage object, initializing, 887–888 MemoryTest project introduced, 871 shape events, handling, 896–898 storyboard animations, 904–906 title, creating, 874–876 UI, defi ning, 872–874 UI cards, highlighting, 893–894 UI elements, scaling, 901–903 wins, recognizing, 898–899 XAML and See XAML (Windows apps and) Windows API basics of, 606, 609–610 vs MFC, 2, 606 Windows messages application, closing, 629 basics of, 609, 625–626, 665 decoding, 626–629 message categories (MFC), 668–669 message maps (MFC), 666–667 message pumps or loops, 620 message type, 675 in programs (MFC), 667–668 WindowProc() function See WindowProc() function Windows programming, 605–636 See also Win32 applications, creating and executing, 20–23 data types, 610–611 event-driven programs, 609 940 www.it-ebooks.info bindex.indd 940 17/09/12 10:44 AM Windows programs – Words, Sorting from Text (example) messages See Windows messages MFC See MFC (Microsoft Foundation Classes) vs MFC, 2, 606 notation in, 611–612 operating system and, 608–609 Simple Windows API Program (example), 630–631 structure of, 612–613 See also WinMain() function user interface elements, 606–608 vs WindowProc() function, 609, 612, 626–630 Windows API, 606, 609–610 windows defined, 608 Windows programs basics of, 4–5, 608–609 vs console programs, Windows::Foundation::Collections namespace, 857, 858 Windows::UI::Xaml::Controls namespace, 869 WinMain() function basics of, 612–614 completed, 624–625 vs main() function, 613 program windows, creating, 617–619 program windows, initializing, 619 program windows, specifying, 615–617 vs WindowProc() function, 612 windows messages, 620–623 WinRT (Windows Runtime) basics of, 854, 856–857 class types, defi ning, 858–860 namespaces, 856 objects, 856–857 wizards Add Member Variable Wizard, 407, 793–794, 810, 811 Application Wizard, 26–28, 822, 824, 839, 845 Class Wizard, 779–780, 812 Event Handler Wizard, 675–678 MFC Application Wizard, 20–23, 659–661 See also MFC Application Wizard output MFC Class Wizard, 806–807 Win32 Application Wizard, 11 WM_ prefi x, for message IDs, 621, 668 WM_LBUTTONDOWN message handler basics of, 709, 710–711 coordinates and, 750 implementing, 711 modifying, 737 revised version, 751 WM_LBUTTONDOWN messages basics of, 709, 710 capturing mouse images and, 739 drawing and, 712, 728 dropping elements and, 770 WM_LBUTTONUP message handler basics of, 710 capturing mouse images and, 739–740 implementing, 737 WM_LBUTTONUP messages basics of, 709, 710, 711 dealing with, 736–737 WM_MOUSEMOVE message handler basics of, 621, 710, 731–732 completing, 714, 730–731 CreateElement() function, 735–736 drawing mode, setting, 731–733 moving elements and, 766–767 outlining code for, 714 WM_MOUSEMOVE messages basics of, 709, 710, 711 capturing mouse messages and, 739 drawing curves and, 728 WM_PAINT messages, 627 WM_QUIT messages, 629 wmain() function, 18, 39 WNDCLASSEX struct type, 615 WndProc() function See WindowProc() function Words, Sorting from Text (example), 436–441 941 www.it-ebooks.info bindex.indd 941 17/09/12 10:44 AM wrappers, for function objects – zeros wrappers, for function objects, 599–600 WRL (WinRT C++ Template Library), 854 wstring class basics of, 183 character strings and, 418 layout elements, 869–870 parent and child elements, 869 UI elements in, 865–868 XAML basics, 863 XML (eXtensible Markup Language), 863 X Z XAML (Windows apps and) attached properties, 868 control elements, 869 elements, 863–865 event handling, 870–871 zeros bitwise AND operator and, 72 decimal integer values and, 46 942 www.it-ebooks.info bindex.indd 942 17/09/12 10:44 AM www.it-ebooks.info badvert.indd 943 17/09/12 6:57 PM Try Safari Books Online FREE for 15 days + 15% off for up to 12 Months* Read this book for free online—along with thousands of others— with this 15-day trial offer With Safari Books Online, you can experience searchable, unlimited access to thousands of technology, digital media and professional development books and videos from dozens of leading publishers With one low monthly or yearly subscription price, you get: • Access to hundreds of expert-led instructional videos on today’s hottest topics • Sample code to help accelerate a wide variety of software projects • Robust organizing features including favorites, highlights, tags, notes, mash-ups and more • Mobile access using any device with a browser • Rough Cuts pre-published manuscripts START YOUR FREE TRIAL TODAY! Visit www.safaribooksonline.com/wrox60 to get started *Available to new subscribers only Discount applies to the Safari Library and is valid for first 12 consecutive monthly billing cycles Safari Library is not available in all countries www.it-ebooks.info badvert.indd 944 17/09/12 6:57 PM Related Wrox Books Beginning ASP.NET 4.5 ISBN: 978-1-118-31180-6 Featuring a user-friendly, step-by-step format, the book guides you through customizing the IDE, building a Planet Wrox website example, working with files and web forms, designing web pages, displaying and updating data, creating tables, and much more With this resource in hand, you will be completely at ease learning ASP.NET 4.5 Beginning Visual C# 2012 ISBN 978-1-118-31441-8 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 C++, 2nd Edition ISBN: 978-0-470-93244-5 With this no-nonsense book, you will learn to conquer the latest version of the C++ language: C++11 The authors share real-world examples, decipher little-known features of C++, and reveal the significant changes to C++ that accompany the latest release Ultimately, you’ll discover programming methodologies, reusable design patterns, and good programming style that will increase the quality of your code and improve your programming efficiency Professional C# 2012 and NET 4.5 ISBN 978-1-118-31442-5 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 2012 with C#, and more Professional Visual Basic 2012 and NET 4.5 ISBN: 978-1-118-31445-6 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 2012 Packed with helpful examples, this comprehensive guide examines the features of Visual Studio 2012, and walks you through every facet of the Integrated Development Environment (IDE), from common tasks and functions to its powerful tools Professional Visual Studio 2012 ISBN: 978-1-118-33770-7 This book is what you need to get up and running quickly on Visual Studio 2012 Written by a Microsoft Visual C# MVP, it guides you through the integrated development environment (IDE), showing you how to maximize each of the tools and features Visual Basic 2012 Programmer’s Reference ISBN: 978-1-118-31407-4 Visual Basic 2012 is packed with powerful features and this book will help you master them all You’ll gain a solid understanding of essential Visual Basic topics and begin applying the information to perform a host of important development tasks The tutorials inside are filled with code examples and the best methods for using them to write your own programs www.it-ebooks.info Related Wrox Books Beginning ASP.NET 4.5 ISBN: 978-1-118-31180-6 Featuring a user-friendly, step-by-step format, the book guides you through customizing the IDE, building a Planet Wrox website example, working with files and web forms, designing web pages, displaying and updating data, creating tables, and much more With this resource in hand, you will be completely at ease learning ASP.NET 4.5 Beginning Visual C# 2012 ISBN 978-1-118-31441-8 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 C++, 2nd Edition ISBN: 978-0-470-93244-5 With this no-nonsense book, you will learn to conquer the latest version of the C++ language: C++11 The authors share real-world examples, decipher little-known features of C++, and reveal the significant changes to C++ that accompany the latest release Ultimately, you’ll discover programming methodologies, reusable design patterns, and good programming style that will increase the quality of your code and improve your programming efficiency Professional C# 2012 and NET 4.5 ISBN 978-1-118-31442-5 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 2012 with C#, and more Professional Visual Basic 2012 and NET 4.5 ISBN: 978-1-118-31445-6 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 2012 Packed with helpful examples, this comprehensive guide examines the features of Visual Studio 2012, and walks you through every facet of the Integrated Development Environment (IDE), from common tasks and functions to its powerful tools Professional Visual Studio 2012 ISBN: 978-1-118-33770-7 This book is what you need to get up and running quickly on Visual Studio 2012 Written by a Microsoft Visual C# MVP, it guides you through the integrated development environment (IDE), showing you how to maximize each of the tools and features Visual Basic 2012 Programmer’s Reference ISBN: 978-1-118-31407-4 Visual Basic 2012 is packed with powerful features and this book will help you master them all You’ll gain a solid understanding of essential Visual Basic topics and begin applying the information to perform a host of important development tasks The tutorials inside are filled with code examples and the best methods for using them to write your own programs www.it-ebooks.info ... PM IVOR HORTON’S BEGINNING ® Visual C ++ 2012 www.it-ebooks.info ffirs.indd iii 17/09/12 6:32 PM www.it-ebooks.info ffirs.indd iv 17/09/12 6:32 PM IVOR HORTON’S BEGINNING ® Visual C++ 2012 Ivor. .. 17/09/12 6:32 PM Ivor Horton’s Beginning Visual C++ 2012 Published by John Wiley & Sons, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2012 by Ivor Horton Published... ii 17/09/12 6:32 PM IVOR HORTON’S BEGINNING VISUAL C ++® 2012 INTRODUCTION xxxv CHAPTER Programming with Visual C++

Ngày đăng: 06/03/2019, 14:39

Từ khóa liên quan

Mục lục

  • Ivor Horton's Beginning: Visual C++® 2012

  • Copyright

  • About the Author

  • About the Technical Editor

  • Credits

  • Acknowledgments

  • Contents

  • Introduction

    • Who this Book is for

    • What this Book Covers

    • How this Book is Structured

    • What you need to use this Book

    • Conventions

    • Source Code

    • Exercises

    • Errata

    • P2P.Wrox.Com

  • Chapter 1: Programming with Visual C++

    • Learning with Visual C++

    • Writing C++ Applications

    • Learning Desktop Applications Programming

      • Learning C++

      • Console Applications

      • Windows Programming Concepts

    • What Is the Integrated Development Environment?

      • The Editor

      • The Compiler

      • The Linker

      • The Libraries

    • Using the IDE

      • Toolbar Options

      • Dockable Toolbars

      • Documentation

      • Projects and Solutions

        • Defining a Project

        • Debug and Release Versions of Your Program

        • Executing the Program

        • Dealing with Errors

      • Setting Options in Visual C++

      • Creating and Executing Windows Applications

        • Creating an MFC Application

        • Building and Executing the MFC Application

    • Summary

  • Chapter 2: Data, Variables, and Calculations

    • The Structure of a C++ Program

      • Program Comments

      • The # include Directive — Header Files

      • Namespaces and the Using Declaration

      • The main() Function

      • Program Statements

      • Whitespace

      • Statement Blocks

      • Automatically Generated Console Programs

        • Precompiled Header Files

        • Main Function Names

    • Defining Variables

      • Naming Variables

      • Keywords in C++

      • Declaring Variables

      • Initial Values for Variables

    • Fundamental Data Types

      • Integer Variables

      • Character Data Types

      • Integer Type Modifiers

      • The Boolean Type

      • Floating-Point Types

      • Fundamental Types in C++

      • Literals

      • Defining Synonyms for Data Types

    • Basic Input/Output Operations

      • Input from the Keyboard

      • Output to the Command Line

      • Formatting the Output

      • Escape Sequences

    • Calculating in C++

      • The Assignment Statement

      • Arithmetic Operations

        • The const Modifier

        • Constant Expressions

        • Program Input

        • Calculating the Result

        • Displaying the Result

      • Calculating a Remainder

      • Modifying a Variable

      • The Increment and Decrement Operators

      • The Sequence of Calculation

        • Operator Precedence

    • Type Conversion and Casting

      • Type Conversion in Assignments

      • Explicit Type Conversion

      • Old-Style Casts

    • The auto Keyword

    • Discovering Types

    • The Bitwise Operators

      • The Bitwise AND

      • The Bitwise OR

      • The Bitwise Exclusive OR

      • The Bitwise NOT

      • The Bitwise Shift Operators

    • Introducing Lvalues and Rvalues

    • Understanding Storage Duration and Scope

      • Automatic Variables

      • Positioning Variable Declarations

      • Global Variables

      • Static Variables

    • Variables with Specific Sets of Values

      • Old Enumerations

      • Type-Safe Enumerations

    • Namespaces

      • Declaring a Namespace

      • Multiple Namespaces

    • Summary

  • Chapter 3: Decisions and Loops

    • Comparing Values

      • The if Statement

      • Nested if Statements

        • The Extended if Statement

      • Nested if-else Statements

      • Logical Operators and Expressions

        • Logical AND

        • Logical OR

        • Logical NOT

      • The Conditional Operator

      • The switch Statement

      • Unconditional Branching

    • Repeating a Block of Statements

      • What Is a Loop?

      • Variations on the for Loop

        • Using the continue Statement

        • Floating-Point Loop Counters

      • The while Loop

      • The do-while Loop

      • The Range-Based for Loop

      • Nested Loops

    • Summary

  • Chapter 4: Arrays, Strings, and Pointers

    • Handling Multiple Data Values of the Same Type

      • Arrays

      • Declaring Arrays

      • Initializing Arrays

      • Using the Range-Based for Loop

      • Character Arrays and String Handling

        • String Input

        • Using the Range-Based for Loop with Strings

      • Multidimensional Arrays

        • Initializing Multidimensional Arrays

    • Indirect Data Access

      • What Is a Pointer?

      • Declaring Pointers

        • The Address-Of Operator

      • Using Pointers

        • The Indirection Operator

        • Why Use Pointers?

      • Initializing Pointers

        • Pointers to char

      • The sizeof Operator

      • Constant Pointers and Pointers to Constants

      • Pointers and Arrays

        • Pointer Arithmetic

        • Using Pointers with Multidimensional Arrays

        • Pointer Notation with Multidimensional Arrays

    • Dynamic Memory Allocation

      • The Free Store, Alias the Heap

      • The new and delete Operators

      • Allocating Memory Dynamically for Arrays

      • Dynamic Allocation of Multidimensional Arrays

    • Using References

      • What Is a Reference?

      • Declaring and Initializing Lvalue References

      • Using References in a Range-Based for Loop

      • Rvalue References

    • Library Functions for Strings

      • Finding the Length of a Null-Terminated String

      • Joining Null-Terminated Strings

      • Copying Null-Terminated Strings

      • Comparing Null-Terminated Strings

      • Searching Null-Terminated Strings

    • Summary

  • Chapter 5: Introducing Structure into your Programs

    • Understanding Functions

      • Why Do You Need Functions?

      • Structure of a Function

        • The Function Header

        • The Function Body

        • The return Statement

      • Alternative Function Syntax

      • Using a Function

        • Function Prototypes

    • Passing Arguments to a Function

      • The Pass-by-Value Mechanism

      • Pointers as Arguments to a Function

      • Passing Arrays to a Function

        • Passing Multidimensional Arrays to a Function

      • References as Arguments to a Function

      • Use of the const Modifier

      • Rvalue Reference Parameters

      • Arguments to main( )

      • Accepting a Variable Number of Function Arguments

    • Returning Values from a Function

      • Returning a Pointer

        • A Cast-Iron Rule for Returning Addresses

      • Returning a Reference

        • A Teflon-Coated Rule: Returning References

      • Static Variables in a Function

    • Recursive Function Calls

      • Using Recursion

    • Summary

  • Chapter 6: More about Program Structure

    • Pointers to Functions

      • Declaring Pointers to Functions

      • A Pointer to a Function as an Argument

      • Arrays of Pointers to Functions

    • Initializing Function Parameters

    • Exceptions

      • Throwing Exceptions

      • Catching Exceptions

      • Rethrowing Exceptions

      • Exception Handling in the MFC

    • Handling Memory Allocation Errors

    • Function Overloading

      • What Is Function Overloading?

      • Reference Types and Overload Selection

      • When to Overload Functions

    • Function Templates

      • Using a Function Template

    • Using the decltype Operator

    • An Example Using Functions

      • Implementing a Calculator

        • Analyzing the Problem

      • Eliminating Blanks from a String

        • How the Function Functions

      • Evaluating an Expression

        • How the Function Functions

      • Getting the Value of a Term

        • How the Function Functions

      • Analyzing a Number

        • How the Function Functions

      • Putting the Program Together

        • How the Function Functions

      • Extending the Program

        • How the Function Functions

      • Extracting a Substring

        • How the Function Functions

      • Running the Modified Program

    • Summary

  • Chapter 7: Defining Your Own Data Types

    • The struct in C++

      • What Is a struct?

      • Defining a struct

      • Initializing a struct

      • Accessing the Members of a struct

      • IntelliSense Assistance with Structures

      • The struct RECT

      • Using Pointers with a struct

        • Accessing Structure Members through a Pointer

        • The Indirect Member Selection Operator

    • Types, Objects, Classes, and Instances

      • First Class

      • Operations on Classes

      • Terminology

    • Understanding Classes

      • Defining a Class

        • Access Control in a Class

      • Declaring Objects of a Class

      • Accessing the Data Members of a Class

      • Member Functions of a Class

      • Positioning a Member Function Definition

      • Inline Functions

    • Class Constructors

      • What Is a Constructor?

      • The Default Constructor

      • Default Parameter Values

      • Using an Initialization List in a Constructor

      • Making a Constructor Explicit

    • Private Members of a Class

      • Accessing private Class Members

      • The friend Functions of a Class

        • Placing friend Function Definitions Inside the Class

      • The Default Copy Constructor

    • The Pointer this

    • const Objects

      • const Member Functions of a Class

      • Member Function Definitions Outside the Class

    • Arrays of Objects

    • Static Members of a Class

      • Static Data Members

      • Static Function Members of a Class

    • Pointers and References to Objects

      • Pointers to Objects

      • References to Class Objects

        • Implementing a Copy Constructor

    • Summary

  • Chapter 8: More on Classes

    • Class Destructors

      • What Is a Destructor?

      • The Default Destructor

      • Destructors and Dynamic Memory Allocation

    • Implementing a Copy Constructor

    • Sharing Memory Between Variables

      • Defining Unions

      • Anonymous Unions

      • Unions in Classes and Structures

    • Operator Overloading

      • Implementing an Overloaded Operator

      • Implementing Full Support for Comparison Operators

      • Overloading the Assignment Operator

        • Fixing the Problem

      • Overloading the Addition Operator

      • Overloading the Increment and Decrement Operators

      • Overloading the Function Call Operator

    • The Object Copying Problem

      • Avoiding Unnecessary Copy Operations

      • Applying Rvalue Reference Parameters

      • Named Objects are Lvalues

    • Default Class Members

    • Class Templates

      • Defining a Class Template

        • Template Member Functions

      • Creating Objects from a Class Template

      • Class Templates with Multiple Parameters

      • Templates for Function Objects

    • Perfect Forwarding

    • Using Classes

      • The Idea of a Class Interface

      • Defining the Problem

      • Implementing the CBox Class

        • Comparing CBox Objects

        • Combining CBox Objects

        • Analyzing CBox Objects

    • Organizing Your Program Code

      • Naming Program Files

    • Library Classes for Strings

      • Creating String Objects

      • Concatenating Strings

      • Accessing and Modifying Strings

      • Comparing Strings

      • Searching Strings

    • Summary

  • Chapter 9: Class Inheritance and Virtual Functions

    • Object-Oriented Programming Basics

    • Inheritance in Classes

      • What Is a Base Class?

      • Deriving Classes from a Base Class

    • Access Control Under Inheritance

      • Constructor Operation in a Derived Class

      • Declaring Protected Class Members

      • The Access Level of Inherited Class Members

    • The Copy Constructor in a Derived Class

    • Preventing Class Derivation

    • Class Members as Friends

      • Friend Classes

      • Limitations on Class Friendship

    • Virtual Functions

      • What Is a Virtual Function?

      • Ensuring Correct Virtual Function Operation

      • Preventing Function Overriding

      • Using Pointers to Class Objects

      • Using References with Virtual Functions

        • Incomplete Class Declaration

      • Pure Virtual Functions

      • Abstract Classes

      • Indirect Base Classes

      • Virtual Destructors

    • Casting Between Class Types

    • Nested Classes

    • Summary

  • Chapter 10: The Standard Template Library

    • What Is the Standard Template Library?

      • Containers

        • Allocators

        • Comparators

      • Container Adapters

      • Iterators

        • Iterator Categories

        • SCARY Iterators

        • std::begin( ) and std::end( ) Functions

    • Smart Pointers

      • Using unique_ptr Objects

      • Using shared_ptr Objects

      • Accessing the Raw Pointer in a Smart Pointer

      • Casting SmartPointers

    • Algorithms

    • Function Objects in the STL

    • Function Adapters

    • The Range of STL Containers

    • Sequence Containers

      • Creating Vector Containers

      • The Capacity and Size of a Vector Container

      • Accessing the Elements in a Vector

      • Inserting and Deleting Elements in a Vector

        • Insert Operations

        • Emplace Operations

        • Erase Operations

        • Swap and Assign Operations

      • Storing Class Objects in a Vector

      • Sorting Vector Elements

      • Storing Pointers in a Vector

      • Array Containers

      • Double-Ended Queue Containers

      • Using List Containers

        • Adding Elements to a List

        • Accessing Elements in a List

        • Sorting List Elements

        • Other Operations on Lists

      • Using forward_list Containers

      • Using Other Sequence Containers

        • Queue Containers

        • Priority Queue Containers

        • Stack Containers

      • The tuple Class Template

    • Associative Containers

      • Using Map Containers

        • Storing Objects

        • Accessing Objects

        • Other Map Operations

      • Using a Multimap Container

    • More on Iterators

      • Using Input Stream Iterators

      • Using Inserter Iterators

      • Using Output Stream Iterators

    • More on Function Objects

    • More on Algorithms

    • Type Traits and Static Assertions

    • Lambda Expressions

      • The Capture Clause

      • Capturing Specific Variables

      • Templates and Lambda Expressions

      • Naming a Lambda Expression

    • Summary

  • Chapter 11: Windows Programming Concepts

    • Windows Programming Basics

      • Elements of a Window

      • Windows Programs and the Operating System

      • Event-Driven Programs

      • Windows Messages

      • The Windows API

      • Windows Data Types

      • Notation in Windows Programs

    • The Structure of a Windows Program

      • The WinMain( ) Function

        • Specifying a Program Window

        • Creating a Program Window

        • Initializing the Program Window

        • Dealing with Windows Messages

        • A Complete WinMain( ) Function

        • How It Works

      • Processing Windows Messages

        • The WindowProc( ) Function

        • Decoding a Windows Message

        • Ending the Program

        • A Complete WindowProc( ) Function

        • How It Works

    • The Microsoft Foundation Classes

      • MFC Notation

      • How an MFC Program Is Structured

    • Summary

  • Chapter 12: Windows Programming with the Microsoft Foundation Classes (MFC)

    • The MFC Document/View Concept

      • What Is a Document?

      • Document Interfaces

      • What Is a View?

      • Linking a Document and Its Views

        • Document Templates

        • Document Template Classes

      • Your Application and MFC

    • Creating MFC Applications

      • Creating an SDI Application

      • MFC Application Wizard Output

        • Viewing Project Files

        • Viewing Classes

        • The Class Definitions

        • Creating an Executable Module

        • Running the Program

        • How the Program Works

      • Creating an MDI Application

        • Running the Program

    • Summary

  • Chapter 13: Working With Menus and Toolbars

    • Communicating with Windows

      • Understanding Message Maps

        • Message Handler Definitions

      • Message Categories

      • Handling Messages in Your Program

        • How Command Messages Are Processed

    • Extending the Sketcher Program

    • Elements of a Menu

      • Creating and Editing Menu Resources

        • Adding a Menu Item to the Menu Bar

        • Adding Items to the Element Menu

        • Modifying Existing Menu Items

        • Completing the Menu

    • Adding Menu Message Handlers

      • Choosing a Class to Handle Menu Messages

      • Creating Menu Message Handlers

      • Implementing Menu Message Handlers

        • Adding Members to Store Color and Element Mode

        • Defining Element and Color Types

        • Initializing the Color and Element Type Members

        • Implementing Menu Command Message Handlers

        • Running the Extended Example

      • Adding Menu Update Message Handlers

        • Coding a Command Update Handler

        • Exercising the Update Handlers

    • Adding Toolbar Buttons

      • Editing Toolbar Button Properties

      • Exercising the Toolbar Buttons

      • Adding Tooltips

    • Summary

  • Chapter 14: Drawing in a Window

    • Basics of Drawing in a Window

      • The Window Client Area

      • The Windows Graphical Device Interface

        • Working with a Device Context

        • Mapping Modes

    • The MFC Drawing Mechanism

      • The View Class in Your Application

        • The OnDraw( ) Member Function

      • The CDC Class

        • Displaying Graphics

        • Drawing in Color

    • Drawing Graphics in Practice

    • Programming for the Mouse

      • Messages from the Mouse

        • WM_LBUTTONDOWN

        • WM_MOUSEMOVE

        • WM_LBUTTONUP

      • Mouse Message Handlers

      • Drawing Using the Mouse

        • Getting the Client Area Redrawn

        • Defining Element Classes

        • The CElement Class

        • The CLine Class

        • The CRectangle Class

        • The CCircle Class

        • The CCurve Class

        • Completing the Mouse Message Handlers

    • Drawing a Sketch

      • Running the Example

      • Capturing Mouse Messages

    • Summary

  • Chapter 15: Improving the View

    • Sketcher Limitations

    • Improving the View

      • Updating Multiple Views

      • Scrolling Views

        • Logical Coordinates and Client Coordinates

        • Dealing with Client Coordinates

      • Using MM_LOENGLISH Mapping Mode

    • Deleting and Moving Elements

    • Implementing a Context Menu

      • Associating a Menu with a Class

      • Checking Context Menu Items

    • Identifying an Element under the Cursor

      • Exercising the Context Menus

      • Highlighting Elements

        • Drawing Highlighted Elements

        • Exercising the Highlights

      • Implementing Move and Delete

        • Deleting an Element

        • Moving an Element

        • Updating Other Views

        • Getting the Elements to Move Themselves

        • Dropping the Element

        • Exercising the Application

    • Dealing with Masked Elements

    • Summary

  • Chapter 16: Working with Dialogs and Controls

    • Understanding Dialogs

    • Understanding Controls

    • Creating a Dialog Resource

      • Adding Controls to a Dialog

      • Testing the Dialog

    • Programming for a Dialog

      • Adding a Dialog Class

      • Modal and Modeless Dialogs

      • Displaying a Dialog

        • Displaying the Dialog

        • Code to Close the Dialog

    • Supporting the Dialog Controls

      • Initializing Dialog Controls

      • Handling Radio Button Messages

    • Completing Dialog Operations

      • Adding Pen Widths to the Document

      • Adding Pen Widths to the Elements

      • Creating Elements in the View

      • Exercising the Dialog

    • Using a Spin Button Control

      • Adding a Scale Menu Item and Toolbar Button

      • Creating the Spin Button

        • The Controls' Tab Sequence

      • Generating the Scale Dialog Class

        • Dialog Data Exchange and Validation

        • Initializing the Dialog

      • Displaying the Spin Button

    • Using the Scale Factor

      • Scalable Mapping Modes

      • Setting the Document Size

      • Setting the Mapping Mode

      • Implementing Scrolling with Scaling

        • Setting Up the Scrollbars

    • Working with Status Bars

      • Adding a Status Bar to a Frame

        • Creating Status Bar Panes

        • Updating the Status Bar

    • The CString Class

    • Using an Edit Box Control

      • Creating an Edit Box Resource

      • Creating the Dialog Class

      • Adding the Text Menu Item

      • Defining a Text Element

      • Implementing the CText Class

        • The CText Constructor

        • Creating a Text Element

        • Drawing a CText Object

        • Moving a CText Object

    • Summary

  • Chapter 17: Storing and Printing Documents

    • Understanding Serialization

    • Serializing a Document

      • Serialization in the Document Class Definition

      • Serialization in the Document Class Implementation

        • The Serialize( ) Function

        • The CArchive Class

      • Functionality of CObject-Based Classes

        • The Macros that Add Serialization to a Class

      • How Serialization Works

      • How to Implement Serialization for a Class

    • Applying Serialization

      • Recording Document Changes

      • Serializing the Document

      • Serializing the Element Classes

        • The Serialize( ) Functions for the Element Classes

    • Exercising Serialization

    • Printing a Document

      • The Printing Process

        • The CPrintInfo Class

    • Implementing Multipage Printing

      • Getting the Overall Document Size

      • Storing Print Data

      • Preparing to Print

      • Cleaning Up after Printing

      • Preparing the Device Context

      • Printing the Document

      • Getting a Printout of the Document

    • Summary

  • Chapter 18: Programming Windows 8 Apps

    • Understanding Windows 8 Apps

    • Developing Windows 8 Apps

    • Windows Runtime Concepts

      • WinRT Namespaces

      • WinRT Objects

    • C++ Component Extensions (C++/CX)

      • C++/CX Namespaces

      • Defining WinRT Class Types

      • Variables of Ref Class Types

      • Accessing Members of a Ref Class Object

      • Event Handler Functions

      • Casting Ref Class References

    • The eXtensible Application Markup Language (XAML)

      • XAML Elements

      • UI Elements in XAML

      • Attached Properties

      • Parents and Children

      • Control Elements

      • Layout Elements

      • Handling Events for UI Elements

    • Creating a Windows 8 App

      • Application Files

      • Defining the User Interface

      • Creating the Title

      • Adding Game Controls

      • Creating a Grid to Contain the Cards

        • Defining a Card

        • Creating a Card

        • Adding Event Handling

        • Creating All the Cards

      • Implementing Game Operations

        • Defining the Card Class

        • Adding Data Members to the MainPage Class

        • Adding Function Members

      • Initialize the MainPage Object

      • Initializing the Card Pack

      • Setting Up the Child Elements of cardGrid

      • Initializing the Game

      • Shuffling the Cards

      • Highlighting the UI Cards

      • Handling Card Back Events

      • Handling Shape Events

      • Recognizing a Win

      • Handling Game Control Button Events

    • Scaling UI Elements

    • Transitions

      • Application Startup Transitions

      • Storyboard Animations

    • Summary

  • Index

  • Advertisement

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan