Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
C++ Windows Programming
C++ Windows Programming

C++ Windows Programming: Develop real-world applications in Windows.

By Stefan Björnander
€41.99
Book Sep 2016 588 pages 1st Edition
eBook
€32.99 €22.99
Print
€41.99
Subscription
€14.99 Monthly
eBook
€32.99 €22.99
Print
€41.99
Subscription
€14.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Sep 12, 2016
Length 588 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781786464224
Vendor :
Microsoft
Category :

Estimated delivery fee Deliver to Estonia

Premium 7 - 10 business days

€26.95
(Includes tracking information)
Table of content icon View table of contents Preview book icon Preview Book

C++ Windows Programming

Chapter 1. Introduction

The purpose of this book is to learn how to develop applications in Windows. In order to do so, I have developed Small Windows, which is a C++ object-oriented class library for graphical applications in Windows.

The idea is to guide you into Windows programming by introducing increasingly more advanced applications written in C++ with Small Windows, thereby hiding the technical details of the Windows 32-bit Applications Programming Interface (Win32 API), which is the underlying library for Windows development. With this approach, we can focus on the business logic without struggling with the underlying technical details. If you are interested in knowing how the Win32 API works, the second part of this book gives a detailed description of how Small Windows is implemented.

This book is made up of two parts, where the first part describes the applications developed in C++ with Small Windows. While some books have many examples, this book only includes six examples, among which the last four are rather advanced: the Tetris game, a drawing program, a word processor, and a spreadsheet program. Note that this book is not only a tutorial about Windows programming, but also a tutorial about how to develop object-oriented graphical applications.

The second part holds a detailed description of the implementation of Small Windows in the Win32 API. Note that the Win32 API is not introduced until the second part. Some of you may be satisfied with the high level aspects of Small Windows and only want to study application-specific problems, while others may want to read the second part in order to understand how the classes, methods, and macros of Small Windows are implemented in the Win32 API.

Naturally, I am aware of the existence of modern object-oriented class libraries for Windows. However, the purpose of those libraries is to make it easier for the developer by hiding the details of the architecture, which also prevents the developer from using the Windows architecture to its full extent. Even though the Win32 API has been around for a while, I regard it as the best way to develop professional Windows applications and to understand the Windows architecture.

All source code is given in this book; it is also available as a Visual Studio solution.

The library


This section gives an introduction to Small Windows. The first part of a Small Windows application is the MainWindow function. It corresponds to main in regular C++. Its task is to set the name of the application and create the main window of the application.

In this book we talk about definitions and declarations. A declaration is just a notification for the compiler, while a definition is what defines the feature. Below is the declaration of the MainWindow function. Its definition is left to the user of Small Windows.

void MainWindow(vector<String>argumentList,
                SmallWindows::WindowShow windowShow);

Simply put, in Windows the application does not take any initiative; rather, it waits for messages and reacts when it receives them. Informally speaking, you do not call Windows, Windows calls you.

The most central part of Small Windows is the Application class. In Windows, each event generates a message that is sent to the window that has input focus at the moment. The Application class implements the RunMessageLoop method, which makes sure that each message is sent to the correct window. It also closes the application when a special quit message is sent.

The creation of a window takes place in two steps. In the first step, the RegisterWindowClasses method sets features such as style, color, and appearance. Note that Windows classes are not C++ classes:

class Application { 
  public: 
    static int RunMessageLoop(); 
    static void RegisterWindowClasses(HINSTANCE instanceHandle); 
}; 

The next step is to create an individual window, which is done by the Window class. All virtual methods are empty and are intended to be overridden by sub classes shown as follows:

  class Window { 
    public: 

A window can be visible or invisible, enabled or disabled. When a window is enabled, it accepts mouse, touch, and keyboard input:

      void ShowWindow(bool visible); 
      void EnableWindow(bool enable); 

The OnMove and the OnSize methods are called when the window is moved or resized. The OnHelp method is called when the user presses the F1 key or the Help button in a message box:

      virtual void OnMove(Point topLeft); 
      virtual void OnSize(Size windowSize); 
      virtual void OnHelp(); 

The client area is the part of the window that it is possible to paint in. Informally, the client area is the window minus its frame. The contents of the client area can be zoomed. The default zoom factor is 1.0:

      double GetZoom() const; 
      void SetZoom(double zoom); 

The timer can be set to an interval in milliseconds. The OnTimer method is called on every interval. It is possible to set up several timers, as long as they have different identity numbers:

      void SetTimer(int timerId, unsigned int interval); 
      void DropTimer(int timerId); 
      virtual void OnTimer(int timerId); 

The OnMouseDown, OnMouseUp, and OnDoubleClick methods are called when the user presses, releases, or double-clicks on a mouse button. The OnMouseMove method is called when the user moves the mouse with at least one button pressed. The OnMouseWheel method is called when the user moves the mouse wheel with one click:

      virtual void OnMouseDown(MouseButton mouseButtons, 
                           Point mousePoint, bool shiftPressed, 
                           bool controlPressed); 


      virtual void OnMouseUp(MouseButton mouseButtons, 
                           Point mousePoint, bool shiftPressed, 
                           bool controlPressed); 
      virtual void OnDoubleClick(MouseButton mouseButtons, 
                           Point mousePoint, bool shiftPressed, 
                           bool controlPressed); 
      virtual void OnMouseMove(MouseButton mouseButtons, 
                           Point mousePoint, bool shiftPressed, 
                           bool controlPressed); 
      virtual void OnMouseWheel(WheelDirection direction, 
                           bool shiftPressed, bool controlPressed); 

The OnTouchDown, OnTouchMove, and OnTouchDown methods work in the same way as the mouse methods. However, as the user can touch several points at the same time, the methods takes lists of points rather than an individual point:

    virtual void OnTouchDown(vector<Point> pointList); 
    virtual void OnTouchMove(vector<Point> pointList); 
    virtual void OnTouchUp(vector<Point> pointList); 

The OnKeyDown and OnKeyUp methods are called when the user presses or releases a key. If the user presses a graphical key (a key with an ASCII value between 32 and 127, inclusive), the OnChar method is called in between:

      virtual bool OnKeyDown(WORD key, bool shiftPressed, 
                             bool controlPressed); 
      virtual void OnChar(TCHAR tChar); 
      virtual bool OnKeyUp(WORD key, bool shiftPressed, 
                           bool controlPressed); 

The Invalidate method marks a part of the client area (or the whole client area) to be repainted; the area becomes invalidated. The area is cleared before the painting if clear is true. The UpdateWindow method forces a repainting of the invalidated area. It causes the OnPaint method to be called eventually:

      void Invalidate(Rect areaRect, bool clear = true) const; 
      void Invalidate(bool clear = true) const; 
      void UpdateWindow(); 

The OnPaint method is called when some part of the client area needs to be repainted and the OnPrint method is called when it is sent to a printer. Their default behavior is to call the OnDraw method with Paint or Print as the value of the drawMode parameter:

      virtual void OnPaint(Graphics& graphics) const;
      virtual void OnPrint(Graphics& graphics, int page, 
                           int copy, int totalPages) const;
      virtual void OnDraw(Graphics& graphics, DrawMode drawMode)
                          const;

The OnClose method closes the window if TryClose returns true. The OnDestroy method is called when the window is being closed:

      virtual void OnClose(); 
      virtual bool TryClose(); 
      virtual void OnDestroy(); 

The following methods inspect and modify the size and position of the window. Note that we cannot set the size of the client area; it can only be set indirectly by resizing the window:

      Size GetWindowSize() const; 
      void SetWindowSize(Size windowSize); 
      Point GetWindowPosition() const; 
      void SetWindowPosition(Point topLeft); 
      Size GetClientSize() const; 

In the word processor and spreadsheet programs in this book, we handle text and need to calculate the size of individual characters. The following methods calculate the width of a character with a given font. They also calculate the height, ascent, and average character width of a font:

      int GetCharacterWidth(Font font, TCHAR tChar) const; 
      int GetCharacterHeight(Font font) const; 
      int GetCharacterAscent(Font font) const; 
      int GetCharacterAverageWidth(Font font) const; 

The ascent line separates the upper and lower part of a letter, shown as follows:

Finally, the MessageBox method displays a simple message box in the window:

      Answer MessageBox(String message,
                    String caption = TEXT("Error"),
                    ButtonGroup buttonGroup = Ok,
                    Icon icon = NoIcon, bool help = false) const;
};

The Window class also uses the Graphics class responsible for drawing text and geometrical objects in the window. A reference to a Graphics object is sent to the OnPaint, OnPrint, and OnDraw methods in the Window class. It can be used to draw lines, rectangles, and ellipses and to write text:

  class Graphics { 
    public: 
      void DrawLine(Point startPoint, Point endPoint, 
                    Color penColor, PenStyle penStyle = Solid); 
      void DrawRectangle(Rect rect, Color penColor, 
                         PenStyle = Solid); 
      void FillRectangle(Rect rect, Color penColor, 
                       Color brushColor, PenStyle penStyle=Solid); 
      void DrawEllipse(Rect rect, Color penColor, 
                       PenStyle = Solid); 
      void FillEllipse(Rect rect, Color penColor, 
                       Color brushColor, PenStyle penStyle=Solid); 
      void DrawText(Rect areaRect, String text, Font font, 
                    Color textColor, Color backColor, 
                    bool pointsToMeters = true); 
  }; 

The Document class extends the Window class with some functionality common to document-based applications. The scroll thumbs are automatically set to reflect the visible part of the document. The mouse wheel moves the vertical scroll bar one line-height for each click. The height of a line is set by the constructor. The code snippet for it is shown as follows:

  class Document : public Window { 
    public: 

The dirty flag is true when the user has made a change in the document and it needs to be saved. In Document, the dirty flag is set manually, but in the following StandardDocument subclass it is handled by the framework:

      bool IsDirty() const; 
      void SetDirty(bool dirty); 

The caret is the blinking marker that indicates to the user where they should input the next character. The keyboard can be set (with the Insert key) to insert or overwrite mode. The caret is often a thin vertical bar in insert mode and a block with the width of an average character in overwrite mode.

The caret can be set or cleared. For instance, in the word processor, the caret is visible when the user writes text and invisible when the user marks text. When the window gains focus, the caret becomes visible if it has earlier been set. When the window loses focus, the caret becomes invisible, regardless of whether it has earlier been set:

      void SetCaret(Rect caretRect); 
      void ClearCaret(); 
      void OnGainFocus(); 
      void OnLoseFocus(); 

A document may hold a menu bar, which is set by the SetMenuBar method:

      void SetMenuBar(Menu& menuBar); 

The OnDropFiles method is called when the user drops one or several files in the window. Their paths are stored in the path list:

      virtual void OnDropFile(vector<String> pathList); 

The keyboard mode of a document can be set to insert or overwrite as follows:

      KeyboardMode GetKeyboardMode() const; 
      void SetKeyboardMode(KeyboardMode mode); 

The OnHorizontalScroll and OnVerticalScroll methods are called when the user scrolls the bar by clicking on the scroll bar arrows or the scroll bar fields, or dragging the scroll thumbs. The code snippet for it is shown as follows:

      virtual void OnHorizontalScroll(WORD flags,WORD thumbPos=0); 
      virtual void OnVerticalScroll(WORD flags, WORD thumbPos =0); 

There is a large set of methods for inspecting or changing scroll bar settings. The size of a line or page is set by the constructor:

      void SetHorizontalScrollPosition(int scrollPos); 
      int GetHorizontalScrollPosition() const; 
      void SetVerticalScrollPosition(int scrollPos); 
      int GetVerticalScrollPosition() const; 
 
      void SetHorizontalScrollLineWidth(int lineWidth); 
      int GetHorizontalScrollLineHeight() const; 
      void SetVerticalScrollLineHeight(int lineHeight); 
      int GetVerticalScrollLineHeight() const; 
 
      void SetHorizontalScrollPageWidth(int pageWidth); 
      int GetHorizontalScrollPageWidth() const; 
      void SetVerticalScrollPageHeight(int pageHeight); 
      int GetVerticalScrollPageHeight() const; 


 
      void SetHorizontalScrollTotalWidth(int scrollWidth); 
      int GetHorizontalScrollTotalWidth() const; 
      void SetVerticalScrollTotalHeight(int scrollHeight); 
      int GetVerticalScrollTotalHeight() const; 
  }; 

The Menu class handles the menu bar, a menu, a menu item, or a menu item separator (a horizontal bar) in the document. The selection listener is called when the user selects the menu item. The enable, check, and radio listeners are called (unless they are null) when the item is about to become visible. If they return true, the item is enabled or annotated with a check box or radio button:

  class Menu { 
    public: 
      void AddMenu(Menu& menu); 
      void AddSeparator(); 
      void AddItem(String text, VoidListener selection, 
                   BoolListener enable = nullptr, 
                   BoolListener check = nullptr, 
                   BoolListener radio = nullptr); 
  }; 

An accelerator is a shortcut command. For instance, often, the Open item in the File menu is annotated with the text Ctrl+O. This means that you can obtain the same result by pressing the Ctrl key and the O key at the same time, just as if you selected the Open menu item. In both cases, the Open dialog is displayed.

The Accelerator class holds only the TextToAccelerator method. It interprets the menu item text and adds the accelerator, if present, to the accelerator set:

class Accelerator { 
    public: 
      static void TextToAccelerator(String& text, int idemId, 
                                    list<ACCEL>& acceleratorSet); 
  }; 

The StandardDocument class extends the Document class and sets up a framework that takes care of all traditional tasks, such as load and save, and cut, copy, and paste, in a document-based application:

  class StandardDocument : public Document { 
    public: 

The StandardDocument class comes equipped with the common File, Edit, and Help menus. The File menu can optionally (if the print parameter is true) be equipped with menu items for printing and print previewing:

      Menu StandardFileMenu(bool print); 
      Menu StandardEditMenu(); 
      Menu StandardHelpMenu(); 

The ClearDocument method is called when the user selects the New menu item; its task is to clear the document. The WriteDocumentToStream method is called when the user selects the Save or Save As menu item and the ReadDocumentFromStream method is called when the user selects the Open menu item:

      virtual void ClearDocument(); 
      virtual bool WriteDocumentToStream(String name, 
                                         ostream& outStream)const; 
      virtual bool ReadDocumentFromStream(String name, 
                                          istream& inStream); 

The CopyAscii, CopyUnicode, and CopyGeneric methods are called when the user selects the Cut or Copy menu item and the corresponding ready method returns true. The code snippet for it is shown as follows:

      virtual void CopyAscii(vector<String>& textList) const; 
      virtual bool IsCopyAsciiReady() const; 
      virtual void CopyUnicode(vector<String>& textList) const; 
      virtual bool IsCopyUnicodeReady() const; 
      virtual void CopyGeneric(int format, InfoList& infoList)  
                               const; 
      virtual bool IsCopyGenericReady(int format) const; 

In the same way, the PasteAscii, PasteUnicode, and PasteGeneric methods are called when the user selects the Paste menu item and the corresponding ready method returns true:

      virtual void PasteAscii(const vector<String>& textList); 
      virtual bool IsPasteAsciiReady 
                   (const vector<String>& textList) const; 
      virtual void PasteUnicode(const vector<String>& textList); 
      virtual bool IsPasteUnicodeReady 
                   (const vector<String>& textList) const; 
      virtual void PasteGeneric(int format, InfoList& infoList); 
      virtual bool IsPasteGenericReady(int format, 
                                       InfoList& infoList) const; 

The OnDropFile method checks the path list and accepts the drop if exactly one file has the suffix of the document type of the application (set by the constructor):

      void OnDropFile(vector<String> pathList); 
  }; 

In Small Windows, we do not care about the pixel size. Instead, we use logical units that stay the same, regardless of the physical resolution of the screen. We can choose from the following three coordinate systems:

  • LogicalWithScroll: A logical unit is one hundredth of a millimeter, with the current scroll bar settings taken into account. The drawing program and word processor use this system.

  • LogicalWithoutScroll: A logical unit is one hundredth of a millimeter also in this case, but the current scroll bar settings are ignored. The spreadsheet program uses this system.

  • PreviewCoordinate: The client area of the window is set to a fixed logical size when the window is created. This means that the size of the logical units changes when the user changes the window size. The Tetris game and the PreviewDocument class uses this system.

Besides the StandardDocument class, there is also the PrintPreviewDocument, which class that also extends the Document class. It displays one of the pages of a standard document. It is possible for the user to change the page by using the arrow keys and the Page Up and Page Down keys or by using the vertical scroll bar:

  class PrintPreviewDocument : Document { 
    public: 
      PrintPreviewDocument(StandardDocument* parentDocument, 
                  int page = 1, Size pageSize = USLetterPortrait); 
      bool OnKeyDown(WORD key, bool shiftPressed, 
                     bool controlPressed); 
      void OnVerticalScroll(WORD flags, WORD thumbPos = 0); 
      void OnPaint(Graphics& graphics) const; 
  }; 

There are also the simple auxiliary classes:

  • Point: It holds a two-dimensional point (x and y)

  • Size: It holds two-dimensional width and height

  • Rect: It holds the four corners of a rectangle

  • DynamicList: It holds a dynamic list

  • Tree: It holds a tree structure

  • InfoList: It holds a list of generic information that can be transformed into a memory block

The Registry class holds an interface to the Windows Registry, the database in the Windows system that we can use to store values in between the execution of our applications. The Clipboard class holds an interface to the Windows Clipboard, an area in Windows intended for short-term data storage that we can use to store information cut, copied, and pasted between applications.

The Dialog class is designed for customized dialogs. The Control class is the root class for the controls of the dialog. The CheckBox, RadioButton, PushButton, ListBox, and ComboBox classes are classes for the specific controls. The TextField class holds a text field that can be translated to different types by the Converter class. Finally, the PageSetupDialog class extends the Dialog class and implements a dialog with controls and converters.

Summary


This chapter has given an introduction to Small Windows. In Chapter 2, Hello, Small World, we will start to develop applications with Small Windows.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Create diverse applications featuring the versatility of Small Windows C++ library
  • Learn about object-oriented programming in Windows and how to develop a large object-oriented class library in C++
  • Understand how to tackle application-specific problems along with acquiring a deep understanding of the workings of Windows architecture

Description

It is critical that modern developers have the right tools to build practical, user-friendly, and efficient applications in order to compete in today’s market. Through hands-on guidance, this book illustrates and demonstrates C++ best practices and the Small Windows object-oriented class library to ease your development of interactive Windows applications. Begin with a focus on high level application development using Small Windows. Learn how to build four real-world applications which focus on the general problems faced when developing graphical applications. Get essential troubleshooting guidance on drawing, spreadsheet, and word processing applications. Finally finish up with a deep dive into the workings of the Small Windows class library, which will give you all the insights you need to build your own object-oriented class library in C++.

What you will learn

[*] Develop advanced real-world applications in Windows [*] Design and implement a graphical object-oriented class library in C++ [*] Get to grips with the workings of the integral aspects of the Win32 API, such as mouse input, drawing, cut-and-paste, file handling, and drop files [*] Identify general problems when developing graphical applications as well as specific problems regarding drawing, spreadsheet, and word processing applications [*] Implement classes, functions, and macros of the object-oriented class library developed in the book and how we implement its functionality by calling functions and macros in the Win32 API

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Sep 12, 2016
Length 588 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781786464224
Vendor :
Microsoft
Category :

Estimated delivery fee Deliver to Estonia

Premium 7 - 10 business days

€26.95
(Includes tracking information)

Table of Contents

22 Chapters
C++ Windows Programming Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Dedication Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Introduction Chevron down icon Chevron up icon
2. Hello, Small World! Chevron down icon Chevron up icon
3. Building a Tetris Application Chevron down icon Chevron up icon
4. Working with Shapes and Figures Chevron down icon Chevron up icon
5. The Figure Hierarchy Chevron down icon Chevron up icon
6. Building a Word Processor Chevron down icon Chevron up icon
7. Keyboard Input and Character Calculation Chevron down icon Chevron up icon
8. Building a Spreadsheet Application Chevron down icon Chevron up icon
9. Formula Interpretation Chevron down icon Chevron up icon
10. The Framework Chevron down icon Chevron up icon
11. The Document Chevron down icon Chevron up icon
12. The Auxiliary Classes Chevron down icon Chevron up icon
13. The Registry, Clipboard, Standard Dialogs, and Print Preview Chevron down icon Chevron up icon
14. Dialogs, Controls, and Page Setup Chevron down icon Chevron up icon
Rational and Complex Numbers Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela