You are previewing Delphi Cookbook - Second Edition.
O'Reilly logo
Delphi Cookbook - Second Edition

Book Description

Over 60 hands-on recipes to help you master the power of Delphi for cross-platform and mobile development on multiple platforms

About This Book

  • Get to grips with Delphi to build and deploy various cross-platform applications

  • Design, develop, and deploy real-world applications by implementing a single source codebase

  • This swift guide will increase your productivity to develop applications with Delphi

  • Who This Book Is For

    If you are an intermediate developer with a basic knowledge of Delphi and you want to develop cross-platform applications, then this book is for you. Familiarity with the fundamentals of RAD (Rapid Application Development) Studio is expected.

    What You Will Learn

  • Develop visually stunning applications using FireMonkey

  • Deploy LiveBinding effectively with the right OOP approach

  • Create server-side programs to serve RESTful web services and provide data to your mobile apps

  • Use well-defined GUI design patterns to build mobile applications that provide a great user experience

  • Build mobile apps that read data from a remote server efficiently

  • Call the platform native API on Android and iOS even for an unpublished API

  • Manage software customization for your customer by making better use of an extended RTTI

  • Implement the most popular design pattern without wasting too much time on debugging and bug fixing

  • In Detail

    Delphi is a cross-platform Integrated Development Environment (IDE) that supports rapid application development for Microsoft Windows, Apple Mac OS X, Google Android, and Apple iOS. It helps you to concentrate on the real business and save yourself the pain of wandering amid GUI widget details, or having to tackle inter-platform incompatibilities. It also has a wide range of drag-and-drop controls, helping you code your business logic into your business model, and it compiles natively for desktop and mobile platforms.

    This book will teach you how to design and develop applications, deploy them on the cloud platform, and distribute them within an organization via Google Play and other similar platforms.

    You will begin with the basics of Delphi and get acquainted with JSON format strings, XSLT transformations, unicode encodings and various types of streams. We then move on to more advanced topics such as developing higher-order functions and using enumerators and RTTI. You will get an understanding of how Delphi RTL functions and how to use FireMonkey in a VCL application. We will then cover topics such as multithreading, using the parallel programming library and putting Delphi on a server. We will also take a look at the new feature of WebBroker Apache modules and then ride the mobile revolution with FireMonkey.

    By the end of the book, you will be able to develop and deploy cross-platform applications using Delphi.

    Style and approach

    Delphi Cookbook is an easy-to-follow guide, rich with hands-on examples of real-world programming tasks in Delphi.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Delphi Cookbook Second Edition
      1. Table of Contents
      2. Delphi Cookbook Second Edition
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why Subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Delphi Basics
        1. Introduction
        2. Changing your application look and feel with VCL styles and no code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Changing the style of your VCL application at runtime
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Customizing TDBGrid
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        5. Using owner draw combos and listboxes
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Making an owner draw control aware of the VCL styles
          1. Getting ready
          2. How it works…
          3. There's more…
        7. Creating a stack of embedded forms
          1. Getting ready
          2. How it works…
          3. There's more…
        8. Manipulating JSON
          1. Getting ready
          2. How to do it…
          3. There's more…
        9. Manipulating and transforming XML documents
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        10. I/O in the 21st century – knowing the streams
          1. Getting ready
          2. How it works…
          3. There's more…
        11. Creating a Windows service
          1. Getting ready
          2. How it works…
          3. There's more…
            1. Using the TService.LogMessage method
        12. Associating a file extension with your application on Windows
          1. Getting ready
          2. How to do it…
          3. There's more…
        13. Be coherent with the Windows look and feel using TTaskDialog
          1. Getting started
          2. How it works…
          3. There's more…
      9. 2. Becoming a Delphi Language Ninja
        1. Introduction
        2. Fun with anonymous methods – using higher-order functions
          1. Getting ready
          2. How to do it…
          3. There's more…
        3. Writing enumerable types
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        4. RTTI to the rescue – configuring your class at runtime
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        5. Duck typing using RTTI
          1. Getting ready
          2. How to do it…
          3. There's more…
        6. Creating helpers for your classes
          1. Getting ready
          2. How to do it…
          3. There's more…
      10. 3. Knowing Your Friends – the Delphi RTL
        1. Introduction
        2. Check strings with regular expressions
          1. Getting ready
          2. How to do it…
          3. There's more…
        3. Consuming RESTful services using native HTTP(S) client libraries
          1. Getting ready
            1. Some HTTP considerations
          2. How it works…
          3. There's more…
            1. THTTPClient's methods which directly map the HTTP verbs
            2. How to verify that HTTP TRACE is disabled
        4. Cope with the encoded Internet world using System.NetEncodings
          1. Getting ready
          2. How it works…
          3. There's more…
        5. Save space using System.Zip
          1. How it works…
          2. There's more…
        6. Decouple your code using a cross-platform publish/subscribe mechanism
          1. Getting ready…
          2. How it works…
          3. There's more…
      11. 4. Going Cross-Platform with FireMonkey
        1. Introduction
        2. Giving a new appearance to the standard FireMonkey controls using styles
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Creating a styled TListBox
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Impressing your clients with animations
          1. How to do it…
          2. How it works…
          3. See also
        5. Using master/details with LiveBindings
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Showing complex vector shapes using paths
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Using FireMonkey in a VCL application
          1. How to do it…
          2. How it works…
          3. There's more…
        8. Reinventing your GUI also known as mastering Firemonkey controls, shapes, and effects
          1. Getting ready
          2. How it works…
          3. There's more…
      12. 5. The Thousand Faces of Multithreading
        1. Introduction
        2. Synchronizing shared resources with TMonitor
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Talking with the main thread using a thread-safe queue
          1. Getting ready
          2. How to do it…
          3. There's more…
        4. Synchronizing multiple threads using TEvent
          1. Getting ready
          2. How to do it…
          3. There's more…
        5. Displaying a measure on a 2D graph like an oscilloscope
          1. Getting ready
          2. How to do it…
          3. There's more…
        6. Using tasks to make your customer happier
          1. Getting ready
          2. How it works…
          3. There's more…
        7. Monitoring things using futures
          1. Getting ready
          2. How it works…
          3. There's more…
        8. Parallelize using the parallel for
          1. Getting ready
          2. How it works…
          3. There's more…
      13. 6. Putting Delphi on the Server
        1. Introduction
        2. Developing web client JavaScript applications with WebBroker on the server
          1. Getting ready
          2. How it works…
            1. Retrieving the people list
            2. Creating or updating a person
            3. Running the application
          3. There's more…
        3. Converting a console application to a Windows service
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Serializing a dataset to JSON and back
          1. Getting ready
          2. How it works…
          3. There's more…
        5. Serializing objects to JSON and back using RTTI
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Sending a POST HTTP request encoding parameters
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Implementing a RESTful interface using WebBroker
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        8. Controlling remote application using UDP
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        9. Using app tethering to create a companion app
          1. Getting ready
          2. How it works…
          3. There's more…
        10. Creating DataSnap Apache modules
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        11. Creating WebBroker Apache modules
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        12. Using native HTTP(S) client libraries
          1. Getting ready
          2. How it works…
          3. There's more…
      14. 7. Riding the Mobile Revolution with FireMonkey
        1. Introduction
        2. Taking a photo, applying effects, and sharing it
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Using TListView to show and search local data
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more…
        4. Using SQLite databases to handle a to-do list
          1. Getting ready
          2. How to do it…
          3. There's more…
        5. Do not block the main thread!
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Using a styled TListView to handle long lists of data
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. Customizing the TListView
          1. Getting ready
          2. How it works…
          3. There's more…
        8. Taking a photo and location and sending it to a server continuously
          1. Getting ready
          2. How to do it…
            1. The client side
            2. The server-side
          3. There's more…
        9. Talking with the backend
          1. Getting ready
          2. How to do it…
          3. There's more…
        10. Making a phone call from your app!
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        11. Tracking the application's lifecycle
          1. Getting ready
          2. How to do it…
          3. There's more…
      15. 8. Using Specific Platform Features
        1. Introduction
        2. Using Android SDK Java classes
          1. Getting ready
          2. How to do it…
          3. There's more…
        3. Using iOS Objective C SDK classes
          1. Getting ready
          2. How it works…
          3. There's more…
        4. Displaying PDF files in your app
          1. Getting ready
          2. How it works…
            1. Showing the PDF file on Android
            2. Showing the PDF file on iOS
          3. There's more…
            1. Download the PDF file from the server
        5. Sending Android Intents
          1. Getting ready
          2. How it works…
            1. More complex intent – sending a full flagged e-mail
            2. Starting an activity for result – the speech to text engine
          3. There's more…
        6. Letting your phone talk – using the Android TextToSpeech engine
          1. Getting ready
          2. How it works…
          3. There's more…
        7. Using Java classes in Android apps with Java2OP
          1. Getting ready
          2. How to do it…
          3. There's more…
        8. Doing it in the background, the right way – Android services
          1. Getting ready
          2. How it works…
          3. There's more…
      16. Index