Write High-DPI Apps for Windows 8.1

My latest article for MSDN Magazine is now online.

Write High-DPI Apps for Windows 8.1

This one was a long time coming. I think I wrote the first draft over a year ago. I hope you enjoy it. It’s a big deal for Windows apps.

It’s also easier to grasp when you can see it in action, so be sure to check out my latest course where I demonstrate writing high-DPI apps from start to finish.

Articles

I’ve published a few more articles over the last month:

Long Filenames in Windows 8 (Visual Studio Magazine)

Windows 8 finally addresses a longstanding issue with its support for long filenames. While the Windows file systems, notably NTFS, have supported long filenames for longer than I can remember, the Windows shell has been stuck with an antiquated limit of 259 characters. This is the effective limit imposed by the infamous MAX_PATH constant. Fortunately, the Windows shell is beginning to support longer paths; and while it doesn’t yet go far enough, it does provide a new set of path management functions that fully support long filenames.

Using Regular Expressions with Modern C++ (MSDN Magazine)

C++11 introduced a long list of features that are in themselves quite exciting, but if all you see is a list of isolated features, then you’re missing out. The combination of these features makes C++ into the powerhouse that many have grown to appreciate. I’m going to illustrate this point by showing you how to use regular expressions with modern C++. The C++11 standard introduced a powerful regular expression library, but if you use it in isolation—using a traditional C++ programming style—you might find it somewhat tiresome. Unfortunately, this is the way that most of the C++11 libraries tend to be introduced. However, there is some merit in such an approach. If you were looking for a concise example of using some new library, it would be rather overwhelming to be forced into comprehending a slew of new language features at the same time. Still, the combination of C++ language and library features really turns C++ into a productive programming language.

Enjoy!

10 Practical Techniques to Power Your Visual C++ Apps

My latest Pluralsight course is now available online:

10 Practical Techniques to Power Your Visual C++ Apps

Explore practical solutions to ten common problems that can be solved quite effectively with Visual C++.

Visual C++ has a bad reputation for productivity when compared with its .NET counterparts in the Visual Studio family. While I won’t argue with the fact that simple tasks can often be a little more complicated in C++, the benefits are often worthwhile. From faster and more responsive apps to dramatically reduced memory usage and more predictable resource management. These are all critical factors when producing apps for a new generation of increasingly mobile devices.

In this course you’re going to discover many techniques to search, sort and generate text and XML. You’ll discover effective ways to access the web, communicate with web sockets, and access databases on Windows Azure. You’re going to learn how to master long file paths, layered windows, and how to use SQLite. You’ll discover that writing high-DPI applications needn’t be hard and how to apply cryptography to keep the bad guys out. There’s something here for everyone!

Here’s a quick summary.

1. Searching and Sorting Text

Study the topic of searching and sorting text with an emphasis on modern C++, performance, and efficiency. Tradeoffs include accuracy, performance, and simplicity. You’ll learn about modern libraries, concurrency, regular expressions, and memory mapped files. We’ll consider performance analysis and how slow regex and stream I/O really is.

2. Downloading Files with Internet Explorer

Explore some fundamental options provided by the browser to download content from the web. If you want to wield a lot of downloading power with very little effort then this might be what you need. You’ll learn about the browser cache, streams, status and progress reporting, and even how to manipulate console output.

3. Reading and Writing XML

Learn how to use a fast and lightweight XML parser provided by Windows. Discover how to use the XmlLite library, a blazingly fast and efficient way to process and produce XML documents with ease. You’ll learn about error handling, reading and finding elements, creating temporary files and streams. RSS and HTML are used as a simple example to illustrate various aspects of the XmlLite library.

4. Using WebSockets

Learn how to enable bidirectional communication over the web with the WebSocket protocol. We’ll knock together a quick WebSocket server in C# and then dive into the WinHTTP API to discover how you can easily tame the WebSocket protocol from C++. WinHTTP is a classic C-style API so, as always, you’ll discover how to bring it to life with modern C++.

5. Using Databases on Windows Azure

Discover how to use ODBC to create and interact with a SQL database on Windows Azure. Learn how to set up a database server on Windows Azure and how to create databases programmatically from C++. ODBC is particularly troublesome for C++ developers and you’ll learn how to bring it under submission with modern C++. Database servers tend to provide unique error handling challenges. Learn how to harvest good error and information diagnostics, execute statements, work with tables and cursors, and how to bind columns for simplicity.

6. Using SQLite Databases

Discover how to use SQLite, a completely self-contained, serverless, zero-configuration, SQL database engine. SQLite is an open source, public domain library. Find out how to get it and compile it as part of your C++ project. It has its own quirky C-style API but thankfully modern C++ comes to the rescue again. Discover how to create databases, reliably retrieve error information, and execute statements. You’ll also learn how to create statement objects for greater control and simplicity.

7. Working with File Paths

Master long file paths, safe and elegant path management, and recursive directory creation and deletion. Path management is a complex topic that covers security threats and mitigations. Discover how to avoid many pitfalls. Learn what MAX_PATH really means and get to know a safe alternative that provides respite from security concerns, great support for long file paths, better error information, and much more.

8. Creating Layered Windows

Layered windows provide the unique capability of rendering a window where portions of the window’s bounding rectangle are transparent or at least not fully opaque. You’ll learn the essentials of window creation and management. You’ll learn about window regions, simple transparency, color keys, and more. Finally, you’ll discover how to employ Direct2D’s excellent interop services to render a layered window efficiently.

9. Writing High-DPI Applications

Discover how to write beautiful, high-DPI apps that take advantage of the latest per-monitor and dynamic DPI support in Windows. What does High-DPI mean for apps running on Windows 8.1? Discover the new user controls, the legacy of DPI management on Windows, the concept and practicalities of DPI awareness, and the future of high-DPI scaling and responsiveness on Windows.

10. Applying Cryptography

Discover how to use cryptography effectively in your applications, with random number generation, hash functions, and encryption. The sinister art of cryptography need not be out of your reach. This module focuses on the practicalities of cryptography in C++. You’ll learn about algorithm providers, secure random number generation, hashing and hash functions, keys, encryption, and decryption.

Go and watch it now!

If you’d like to follow along you can download the exercise files or simply grab handle.h and debug.h from dx.codeplex.com.

Have you missed one of my previous courses? Master the essentials of COM, DirectX with C++, and even C programming!

Articles

I’ve published a few more articles over the last month:

An API for Simple HTTP Requests (Visual Studio Magazine)

I’ve written in the past about HTTP, how to perform asynchronous HTTP requests efficiently and how to use WebSockets in various ways, but sometimes it pays to keep it simple. There’s certainly a growing need for more sophisticated libraries that handle HTTP requests and that do so in an asynchronous manner, allowing developers to write responsive applications more easily. On the other hand, such libraries tend to be more difficult to use in simple scenarios where I might not need asynchrony. What if I just need a console application to download a file from the Web? A sophisticated asynchronous programming model is often overkill and can add a lot of complexity. Also, responsiveness isn’t really an issue, although some form of progress reporting might still be important. It turns out that, in these situations, some older APIs can come in handy.

Applying the Range-for Statement in C++ (Visual Studio Magazine)

The simplest way to iterate through a sequence with C++11 is to use the range-for statement. Next to auto and nullptr, it’s one of the simplest constructs introduced by the C++11 standard. However, to appreciate where it can take us, we need to remember where we’ve been.

Exploring Fonts with DirectWrite and Modern C++ (MSDN Magazine)

DirectWrite is an incredibly powerful text layout API. It powers practically all of the leading Windows applications and technologies, from the Windows Runtime (WinRT) implementation of XAML and Office 2013, to Internet Explorer 11 and more. It’s not a rendering engine in itself, but has a close relationship with Direct2D, its sibling in the DirectX family. Direct2D is, of course, the premier hardware-accelerated, immediate-mode graphics API.

You can use DirectWrite with Direct2D to provide hardware-­accelerated text rendering. To avoid any confusion, I haven’t written too much about DirectWrite in the past. I didn’t want you to think Direct2D is just the DirectWrite rendering engine. Direct2D is so much more than that. Still, DirectWrite has a lot to offer, and in this month’s column I’ll show you some of what’s possible with DirectWrite and look at how modern C++ can help simplify the programming model.

Enjoy!

Modern C++ Concurrency – Now on Pluralsight!

My latest Pluralsight course is now available: Modern C++ Concurrency

This course is about the practical application of the modern C++ language to the field of concurrency or concurrent programming.

Need more convincing? This course will introduce you to modern C++ concurrency on the Windows operating system. Unfortunately, standard or portable concurrency is still in its infancy so a comprehensive study of concurrency cannot get away from the practical and platform-specific aspects of the craft. As such, this course uses the Windows operating system as the playground to explore concurrency in C++. This course will prepare you with a deep understanding of threads and synchronization at the OS level, including modern synchronization primitives such as slim reader/writer locks and condition variables. You will learn all about the mighty Windows thread pool API and the Concurrency Runtime. Finally, you will be introduced to some of the shortcomings that plague the C++11 Thread Support Library.

Go and watch it now!

If you’d like to follow along you can download the exercise files or simply grab handle.h and debug.h from dx.codeplex.com.

Have you missed one of my previous courses? Master the essentials of COM, DirectX with C++, and even C programming!

Rendering for the Windows Runtime

My latest column in the October 2013 issue of MSDN Magazine is now available online.

This month, I’ll show you how to take this basic skeleton and add support for rendering. The WinRT application model is optimized for rendering with DirectX. I’ll show you how to take what you’ve learned in my previous columns about Direct2D and Direct3D rendering and apply it to your CoreWindow-based WinRT app—specifically using Direct2D 1.1, via the dx.h library. For the most part, the actual Direct2D and Direct3D drawing commands you’ll need to write are the same regardless of whether you’re targeting the desktop or the Windows Runtime. There are, however, some minor differences, and certainly getting it all hooked up in the first place is quite different. So I’ll pick up where I left off last time and show you how to get some pixels on the screen!

Have you missed one of my previous courses? Master the essentials of COM, DirectX with C++, and even C programming!

You can also find me on Twitter at twitter.com/kennykerr.