C++ Windows Programming. Packt

Develop real-world applications in Windows

Stefan Björnander


e-books shop
e-books shop
Purchase Now !
Just with Paypal



Book Details
 Price
 2.00 USD
 Pages
 577 p
 File Size
 12,830 KB
 File Type
 PDF format
 ISBN
 978-1-78646-422-4
 Copyright   
 2016 Packt Publishing 

About the Author
Stefan Björnander holds a master's degree in computer science, and has worked with
software development for many years. He has lectured on programming for the industry
and universities. He has also authored Microsoft Visual C++ Windows Applications by
Example for Packt Publishing, which gained great acclaim.

About the Reviewer
Lou Mauget learned to program long ago at Michigan State University as a physics major,
learning to use software to design a cyclotron. He worked at IBM for 34 years, and after
that, he went on to work for several consulting firms, including a long-term engagement
with the railroad industry. He is currently consulting for Keyhole Software of Leawood,
Kansas. Recently, he designed and coded MockOla, a drag-drop wire-frame prototyping
tool for Keyhole Software. Lou has coded in C++, Java, JavaScript, Python, and newer
languages, as each was conceived. His current interests include reactive functional
programming, containers, Node JS, NoSQL, geospatial systems, mobile, and any new
language or framework. Occasionally, Lou blogs about software technology for Keyhole
Software. He has coauthored three computer books and authored two IBM
DeveloperWorks XML tutorials and a WebSphere Journal LDAP tutorial. Lou coauthored
several J2EE certification tests for IBM. 
He has reviewed books for Packt Publishing, as well as other publications.

Table of Contents
Preface 1
Chapter 1: Introduction 7
The library 8
Summary 17
Chapter 2: Hello, Small World! 18
Hello, Small Windows! 18
The circle application 21
The main window 22
The CircleDocument class 23
The Circle class 31
Summary 34
Chapter 3: Building a Tetris Application 35
The MainWindow function 36
The Tetris window 36
Keyboard input 40
Drawing 41
Input focus 42
The timer 42
New figures 42
Game over 43
New game 44
Deleting and flashing rows 44
Closing the window 46
The TetrisFigure class 47
The red figure 54
The brown figure 55
The turquoise figure 57
The green figure 57
The yellow figure 59
The blue figure 60
The purple figure 61
The GameGrid class 62
Invalidating and drawing squares 63
Chapter 4: Working with Shapes and Figures 66
The MainWindow function 67
The DrawDocument class 67
The application modes 72
The DynamicList class 73
Initialization 74
Mouse input 76
Painting 82
The File menu 83
Cut, copy, and paste 84
The Modify menu 86
The Add menu 90
The cursor 91
Summary 92
Chapter 5: The Figure Hierarchy 93
The DrawFigure class 93
The LineFigure class 97
The ArrowFigure class 105
The RectangleFigure class 112
The EllipseFigure class 119
Summary 124
Chapter 6: Building a Word Processor 125
Auxiliary classes 125
Character information 126
Line information 129
The Paragraph class 131
The MainWindow class 135
The WordDocument class 135
The caret 144
Mouse input 146
Touchscreen 151
Page setup and calculation 152
Painting and drawing 154
File management 157
Cut, copy, and paste 160
Delete 166
Page break 168
Font 169
Alignment 170
Summary 173
Chapter 7: Keyboard Input and Character Calculation 174
Keyboard handling 174
Arrow keys 179
Home and End 183
Shift arrow keys 184
Shift Page Up and Page Down 187
Shift Home and End 187
Control Home and End 188
Shift Control Home and End 189
Neutral keys 189
Visible characters 192
Character calculation 193
Character size and ascent line 194
Line generation 195
Regular and justified rectangle list generation 199
Invalidate rectangle set generation 202
Summary 203
Chapter 8: Building a Spreadsheet Application 204
The MainWindow class 204
The CalcDocument class 205
Mouse input 214
Scrolling and marking 215
Painting 218
Visibility 220
Marking and updating 222
Keyboard input 224
File management 234
Cut, copy, and paste 238
Font and color 245
Alignment 247
Source and target sets 252
Graph searching 254
Error handling 259
Summary 260
Chapter 9: Formula Interpretation 261
Formula interpretation 261
The tokens 264
The tree node 266
The Scanner – Generating the list of tokens 268
The parser – Generating the syntax tree 272
Matrix and reference 286
The reference class 286
The Matrix class 291
The cell 292
Character input 299
Drawing 301
Caret rectangle list generation 302
Formula interpretation 304
File management 312
Further reading 315
Summary 315
Chapter 10: The Framework 316
An overview of Small Windows 316
“Hello” window for the Win32 API 318
The MainWindow function 322
The WinMain function 323
The Application class 324
The Win32 API Windows classes 325
The message loop 326
The Window class 328
Initialization 336
Header and visibility 339
The touch screen 340
Invalidation and window updates 341
Preparing the device context 342
Unit transformation 344
Window size and position 345
Text metrics 347
Closing the window 348
The MessageBox method 349
The Graphics class 355
Summary 361
Chapter 11: The Document 362
The Document class 362
Initialization 366
The Document header 368
The caret 369
The mouse wheel 371
The menu bar 371
The scroll bar 373
The DocumentProc method 379
The Menu class 382
The Accelerator class 387
The StandardDocument class 390
Initialization 395
Standard menus 396
File management 398
Cut, copy, and paste 401
Drop files 407
Page size 408
Page setup 409
Printing 409
Summary 413
Chapter 12: The Auxiliary Classes 414
The Size class 414
The Point class 421
The Rect class 428
The Color class 436
The Font class 442
The Cursor class 446
The DynamicList class 447
The Tree class 460
The InfoList class 463
Strings 466
Summary 469
Chapter 13: The Registry, Clipboard, Standard Dialogs, and Print
Preview 470
The registry 470
The Clipboard class 474
ASCII and Unicode lines 475
Generic information 478
Standard dialogs 480
The Save dialog 480
The Open dialog 483
The Color dialog 485
The Font dialog 487
The Print dialog 488
Print preview 490
Keyboard input 492
Scroll bar 493
Summary 494
Chapter 14: Dialogs, Controls, and Page Setup 495
Custom dialogs 495
Controls 507
The button controls 510
List controls 514
Combo box 518
Label 520
The TextField class 520
Converters 523
Signed integers 523
Unsigned integers 524
Double values 525
Strings 526
Rational numbers 526
Complex numbers 527
Page setup 528
Page setup information 528
The Page Setup dialog 532
The Template function 535
Summary 538
Appendix: Rational and Complex Numbers 539
Rational numbers 539
Complex numbers 545
Summary 558
Index 559

Bookscreen
e-books shop

Preface
Application development has gained massive popularity because of the immense impact it
has on various sectors. In this booming market, it has become critical to have the right set of
tools to enable developers to build practical, user-friendly, and efficient applications. This
book is focused on the use and implementation of Small Windows, which is a C++ objectoriented
class library that eases the development of interactive Windows applications.

What this book covers
Chapter 1, Introduction, gives an introduction to Small Windows, which is a class library
that encapsulates a part of the Win32 API.
Chapter 2, Hello, Small World!, starts by building a (very) small application—the Small
Windows version of the famous Hello World program. Then, we will continue with a (still
rather small) application that handles circles in a window. The user can add and move
circles, change their colors, and save and load circles.
Chapter 3, Building a Tetris Application, explores a version of the classic Tetris game. Seven
different kinds of figure are falling down the screen and the user’s task is to move or rotate
them so that as many rows as possible can be completely filled and removed.
Chapter 4, Working with Shapes and Figures, teaches you how to build a drawing program,
which can be regarded as a more advanced version of the circle application. It is possible to
create and remove figures as well as mark and drag figures.
Chapter 5, The Figure Hierarchy, continues to build the drawing program. We can define a
class hierarchy with lines, arrows, rectangles, and ellipses.
Chapter 6, Building a Word Processor, describes a word processor capable of formatting individual characters.
Chapter 7, Keyboard Input and Character Calculation, discusses how the word processor
handles many keyboard input combinations and calculates the size and position of each individual character.
Chapter 8, Building a Spreadsheet Application, talks about the final application, which is a
spreadsheet program capable of calculating formulas with the four rules of arithmetic. It is
also possible to cut and paste blocks of cells.
Chapter 9, Formula Interpretation, explains that when the user inputs a formula, we need to
interpret it. The process is divided into scanning and parsing, which we will look into in this chapter.
Chapter 10, The Framework, describes the most central part of Small Windows. This chapter
begins the description of Small Windows. The Application class handles the message loop
of the application and the registration of Windows classes. The Window class handles basic window functionality.
Chapter 11, The Document, talks about the document-based Window subclasses, that is, the
Document class that provides basic document functionality, such as menus and
accelerators, and the Standard Document framework, which provides a document-based framework.
Chapter 12, The Auxiliary Classes, explores a set of small auxiliary classes handling points
and sizes, rectangles, colors and fonts, dynamic lists, and tree structures.
Chapter 13, The Registry, Clipboard, Standard Dialogs, and Print Preview, explains the
implementation of the registry and clipboard, the standard dialogs to save and load files,
choosing color or font, or printing a document. The chapter also explains the
implementation a class for print previewing.
Chapter 14, Dialogs, Controls, and Print Setup, describes the possibility to design custom
dialogs with controls such as push buttons, check boxes, radio buttons, list boxes, combo
boxes, and text field. The input of a text field can be converted to any type. Finally, the Print
Setup dialog is a custom dialog annotated with suitable controls.

Who this book is for
This book is for application developers who want a head-first approach into Windows
programming. It will teach you how to develop an object-oriented class library in C++ and
enhanced applications in Windows. Basic knowledge of C++ and the object-oriented
framework is assumed to get the most out of this book.
Loading...
DMCA.com Protection Status