Micro-ISV.asia

Thursday, 16 September 2010

High DPI Support in Windows Vista and 7

Filed under: Programming — Jan Goyvaerts @ 9:35

The screen on the recently released iPhone 4 has twice the resolution or four times the number of pixels than all preceding models. The new resolution is about 300 DPI, which is the resolution at which the human eye can no longer see the individual pixels. By comparison, most desktop monitors are around 96 DPI.

When an app for an older iPhone is run on the iPhone 4, the app doesn’t know the resolution has changed. The iPhone automatically scales the app by 200% so it fills the screen of the new iPhone, without requiring the app to be updated. New apps that indicate they support the iPhone 4 don’t get the automatic scaling, so they can draw themselves at the full resolution on the new screen.

I don’t have an iPhone and don’t write software for it. But when I heard the announcement I thought this was a really clever solution. I wondered why Windows couldn’t do the same so we can finally enjoy high resolution screens on our desktops. New applications could specify in their manifest that they support high resolution screens. Old applications that don’t have such a manifest and don’t know how to scale themselves would be automatically scaled by Windows. That way new applications would look great on new high resolution monitors while old applications would still be perfectly usable.

I did some digging and found out that this is exactly what Microsoft implemented. The new “high DPI” system was introduced with Windows Vista. It was further improved in Windows 7. While Windows Vista requires a reboot after a DPI change, Windows 7 only requires you to log off and log on again. To change the DPI setting in Windows 7, right-click on the desktop. In the context menu select Personalize. In the lower left corner of the personalization window, click Display.

This screen shot shows a Delphi XE application running on Windows 7. The display settings are set to 800 by 600. Scaling is 100% which means the normal 96 DPI that Windows applications have used for decades. (Old VGA and “super VGA” monitors had resolutions around 70 to 80 DPI, but Windows has always pretended that all displays have 96 DPI.)

Windows 7 at 96 DPI

The next screen shot shows the same Delphi XE application and a second application. Scaling is 150% or 144 DPI. Form1 thinks it is running at 96 DPI and looks blurry. Form2 knows it is running at 144 DPI and looks sharp.

Windows 7 at 144 DPI

If we set custom scaling to 200%, the difference is even more dramatic. Be careful with
using high DPI on small screen sizes as I did here. Nothing really fits on the screen any more.

Windows 7 at 192 DPI

The difference between the two Delphi XE applications is that for the second application, I turned off “enable runtime themes” in the Application section in Project Options. This tells Delphi not to add a manifest to the application, so we can add our own. Then I typed {$R PowerGREP4Manifest.res} into the source code to tell Delphi to link in the resource file that contains the manifest for PowerGREP 4. PowerGREP 4 is the first Just Great Software application that supports high DPI environmens. The true tag at the bottom is what tells Windows Vista and Windows 7 that PowerGREP 4 is capable of nicely scaling itself, so Windows doesn’t have to do it on PowerGREP’s behalf.

You can add this manifest to your own applications if you change the description tag at the top. But make sure to actually test your application on a high DPI system. Make sure that everything scales nicely.

Friday, 3 September 2010

More Goodies in Delphi XE and C++Builder XE

Filed under: Programming — Jan Goyvaerts @ 10:58

Delphi XE and C++Builder XE were released on Monday. The eagerly anticipated support for Win64, OS X, and Linux remains on the roadmap for Delphi and C++Builder. The focus for the XE releases seems to be on added goodies.

  • Regular expressions: With regular expression support now part of the RTL, that is one less 3rd party component that you need. The way the RegularExpressions unit is implemented is particularly nice. It uses records instead of classes to mimic .NET’s regex support. It only takes one line of code to use a regex. You don’t need to worry about memory management.
  • Subversion integration: Check out projects from version control and commit your changes without leaving the IDE. The Differences subtab of the History tab in the code editor allows you to quickly compare any two revisions of the file you’re editing. All this works even if you don’t have a subversion client installed, though you’ll probably want to keep the client you have to manage files that you edit outside the Delphi or C++Builder IDE. The CollabNet subversion client that is part of the installer is the command-line svn tool. You don’t need to install it unless you really want to work from the command line.
  • Beyond Compare: Delphi and C++Builder do not include the full directory comparison tool. They do include the file differ that is part of Beyond Compare. If you don’t like the built-in differ on the Differences subtab of the History tab in the code editor, you can make a change in Tools, Options to use the Beyond Compare differ instead.
  • AQTime: AQTime from SmartBear Software is a code profiler that supports a wide range of development tools for Win32 and .NET. Delphi and C++Builder XE include a version of AQTime with reduced functionality. It only works with the XE versions of Delphi and C++Builder, and does not include some of the more advanced profilers. Even so it offers everything most developers need for profiling their applications. AQTime normally costs $599, so that’s a nice bundle even with the limitations.
  • CodeSite: CodeSite from Raize Software is a logging tool. A logging tool can be very helpful for debugging code where breakpoints are cumbersome. The main benefit of CodeSite is that you can log almost anything, including complete Delphi objects. CodeSite can also log what your application does on your customer’s computers if they install a redistributable with the CodeSite logging application (or if you make it part of your own installer).
  • IP*Works: IP*Works is a set of Internet components, much like the Indy components that have shipped with Delphi and C++Builder for many years. Since IP*Works is not written in pure Delphi, Indy is likely a better choice for Delphi developers. IP*Works is included with Delphi and C++Builder mainly because it is also included with RadPHP, which is now part of RAD Studio XE. If you want to use the same internet components in Delphi and PHP, then IP*Works may be an option.

FinalBuilder is only included with the Enterprise and Architect editions of Delphi XE and C++Builder XE. All the other goodies are included with all editions, including the Professional edition.

Thursday, 2 September 2010

RAD Studio XE Now Shipping with 4 Programming Languages

Filed under: Programming — Jan Goyvaerts @ 10:58

Embarcadero shipped RAD Studio XE on Monday. The successor to RAD Studio 2010 now includes 4 development environments:

  • Delphi XE: Develop native 32-bit Windows applications using the Delphi language. Since Delphi now generates Unicode applications, only Windows 2000 and later are supported.
  • C++Builder XE: Same as Delphi XE, but using C++ as the language.
  • Delphi Prism XE: Delphi Prism XE integrates into Visual Studio 2005, 2008, and 2010. If you don’t have Visual Studio, the VS 2010 shell is installed when you install Delphi Prism. Delphi Prism was first included with RAD Studio 2009. It allows you to develop .NET applications using all the frameworks supported by Visual Studio, including WinForms, WPF, and Silverlight. Delphi Prism uses a language that is very similar to Delphi, but not identical. Unlike the Delphi for .NET compiler that was included with RAD Studio 2005 to 2007, it is not intended to make it easy to share code between Win32 and .NET. Instead it is intended to fully exploit the features offered by the .NET framework.
  • RadPHP XE: RAD Studio XE is the first release that includes RadPHP. RadPHP is the new name of Delphi for PHP. The old name was a bit of a misnomer because while RadPHP is inspired by Delphi, they’re totally separate tools. RadPHP is a development tool that looks and feels very much like Delphi and includes a framework very similar to the VCL, but creates web applications using PHP and JavaScript.

All in all that’s quite a bundle. There are 3 editions: Professional, Enterprise, and Architect. Enterprise has all the Professional features plus dbExpress server connectivity, DataSnap (for multi-tier database applications), WebSnap, UML modeling, and build automation. Architect has all the Enterprise features plus database modeling using ER/Studio.

Saturday, 14 August 2010

Delphi XE is Coming

Filed under: Programming — Jan Goyvaerts @ 16:07

The successor of Delphi 2010 will be called Delphi XE rather than Delphi 2011. The first of three sneak previews is now available on Embarcadero’s website. If the video doesn’t play smoothly, try watching it on YouTube.

Embarcadero acquired Delphi and the other Borland developer tools in 2008. Borland itself has since been completely sold of and no longer exists as a company. It seems that Embarcadero is now working on integrating Delphi and the other Borland products into their own product lines.

Embarcadero sells a wide range of database management applications. Previously these tools were sold separately for each database platform. Now these tools can be purchased as one package supporting all databases that the tools are availble for. These cross-database editions are sold under the XE moniker. Delphi has always supported a wide range of databases. In that respect it fits within the XE toolsets. So you could say that XE stands for “cross-platform Embarcadero-style”, where a platform is a database platform rather than an operating system platform.

Embarcadero has also published a new roadmap for Delphi. Project “Fulcrum” on the roadmap is the codename of Delphi XE. Support for Win64, OSX, and Linux remains on the roadmap, in that order. So it’s safe to assume Delphi XE will be Win32-only, as Delphi has been since version 2 back in 1996.

« Previous PageNext Page »