Category Archive for Software Development

Visual Studio 2010 and .NET Framework 4 Release Candidate

Microsoft has released the Release Candidate version of Visual Studio 2010 and the .NET Framework 4.

See Scott Guthrie blog post about it.

Right now it’s available for MSDN subscribers.
On Wednesday 10th of February everyone will be able to get their hands on it 🙂

Two important things to know (from Scott Guthrie blog post):

  • If you have previously installed VS 2010 Beta 2 on your computer you should use Add/Remove Programs (within Windows Control Panel) to remove VS 2010 Beta2 and .NET 4 Beta2 before installing the VS 2010 RC.  Note that VS 2010 RC can be installed on the same machine side-by-side with VS 2008 and VS 2005.
  • Silverlight 3 projects are supported with today’s VS 2010 RC build – however Silverlight 4 projects are not yet supported.  We will be adding VS 2010 RC support for SL4 with the next public Silverlight 4 drop. If you are doing active Silverlight 4 development today we recommend staying with the VS10 Beta 2 build for now.
Share

Visual Studio 2010 and .NET Framework 4 Beta 2

Visual Studio 2010 and .NET Framework 4 Beta 2 are now available. The final version is scheduled for 22nd of March 2010. I’m looking forward to it 🙂

For Visual C++ developers there are lots of new things to look forward to, like parallel programming, MFC ribbon resource editor, easy application local deployment model etc etc…

When you use the .NET Framework you will apparently be able to have deployments with up to 81% reduction in the framework size by using the Client Profile.

According to the press release:

“The company also outlined a simplified product lineup and pricing options for Visual Studio 2010 as well as new benefits for MSDN subscribers, including the Ultimate Offer, available to all active MSDN Premium subscribers at the official product launch on March 22, 2010.”

The product lineup is simplified with the following versions:

  • Microsoft Visual Studio 2010 Ultimate with MSDN. The comprehensive suite of application life-cycle management tools for software teams to help ensure quality results from design to deployment
  • Microsoft Visual Studio 2010 Premium with MSDN. A complete toolset to help developers deliver scalable, high-quality applications
  • Microsoft Visual Studio 2010 Professional with MSDN. The essential tool for basic development tasks to assist developers in implementing their ideas easily

Download Beta 2 now.

Read the full Microsoft press release.

Share

Windows API Code Pack for Microsoft .NET Framework

I just stumbled upon the Windows API Code Pack for the Microsoft .NET Framework. It’s a code pack that allows .NET developers to take advantage of some of the new Windows 7 features.

Features supported by version 0.9 of the code pack are:

  • Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars.
  • Known Folders, Windows 7 Libraries, non-file system containers, and a hierarchy of Shell Namespace entities.
  • Windows 7 Explorer Browser Control.
  • Shell property system.
  • Windows Vista and Windows 7 Common File Dialogs, including custom controls.
  • Windows Vista and Windows 7 Task Dialogs.
  • Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs. (DirectWrite and WIC have partial support)
  • Sensor Platform APIs
  • Extended Linguistic Services APIs
  • Power Management APIs
  • Application Restart and Recovery APIs
  • Network List Manager APIs
  • Command Link control and System defined Shell icons.

Requirements:

  • .NET Framework 3.5 or later.
  • This library targets the Windows 7 RC version, though some of the features will work on the older versions of Windows operating system.
  • DirectX features have dependency on Windows SDK for Windows 7 RC and March 2009 release of DirectX SDK.

There are also a few short 2-minute videos available to show you how easy it is to use some of the above features.

Share

Parallel Pattern Library (PPL) in Visual C++ 2010

Visual C++ 2010 comes with a brand new library called the Parallel Pattern Library or PPL. It is a powerful library that makes writing parallel code easier which is getting more and more important with the current and upcoming multicore CPUs. This article will give an overview of the PPL. Read the rest of this entry »

Share

MFC Restart Manager Support in Visual C++ 2010

Windows Vista introduced the restart manager. It is used to automatically restart an application after it crashes. It can also be used to restart application after a reboot by a Windows Installer or update. If you create a new MFC application using the project wizard in Visual C++ 2010, you will automatically get support for the restart manager. If you want to add support to an existing MFC application, you only need to add 1 line of code to the constructor of your CWinApp or CWinAppEx derived class. Read the rest of this entry »

Share

CTaskDialog in MFC in Visual C++ 2010

Windows Vista introduced the concept of Task Dialogs. Those are a powerful replacement for the standard message boxes. Read the rest of this entry »

Share

SafeInt in Visual C++ 2010

The SafeInt library is a new addition to Visual C++ 2010. It allows you to safely perform arithmetic operations on integers ranging from 8-bit to 64-bit. The SafeInt library will automatically detect arithmetic overflow or divide by zero. Using the SafeInt library is pretty easy. The following piece of code uses the SafeInt library to safely calculate the addition of two 8-bit integers. Read the rest of this entry »

Share

‘auto’ Keyword in Visual C++ 2010

Starting with Visual C++ 2010, the ‘auto’ keyword has a different meaning. Auto is now used as a variable type and it instructs the compiler to figure out the exact type itself. This makes it much easier to define function pointers or to iterate over vectors for example. This post will give a brief overview of how to use the ‘auto’ keyword. Read the rest of this entry »

Share

The ‘Move Constructor’ in Visual C++ 2010

A new feature in Visual C++ 2010 is called Rvalue References. This is a feature from the C++0x standard. One thing that Rvalue References can be used for is to implement move semantics for objects. To add move semantics to a class, we need to implement a move constructor and a move assignment operator (optional). This article will briefly explain the benefits of move constructors and how to write them. Read the rest of this entry »

Share

Introduction to DirectWrite

Microsoft has added two interesting new API’s to Windows 7: Direct2D and DirectWrite. Direct2D replaces GDI and GDI+. It can render more accurate results and has support for hardware acceleration on your graphics hardware. DirectWrite is a new API to render text. It makes it easy to render paragraphs of text that can contain different formatting, coloring, fonts etc. It supports horizontal and vertical alignments, even vertical centering of a paragraph with multiple lines which was not possible with the old text API, etc. This article will give an introduction to the new DirectWrite API. Read the rest of this entry »

Share

How To Use UpdateLayeredWindow

In this post I will briefly explain how to use layered windows and specifically how to use UpdateLayeredWindow.

The first thing you need to do is add the WS_EX_LAYERED style to your window. This can for example be done with a call to CreateWindowEx:

hWnd = CreateWindowEx(WS_EX_LAYERED, szWindowClass, szTitle, 0,
         CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

After your window is created we will load a PNG file with an alpha channel and use UpdateLayeredWindow to render the PNG on the window using the alpha channel of the PNG file as the transparency level for the window. This is done as follows:

// Load our PNG image
CImage img;
img.Load("circle.png");
// Get dimensions
int iWidth = img.GetWidth();
int iHeight = img.GetHeight();
// Make mem DC + mem  bitmap
HDC hdcScreen = GetDC(NULL);
HDC hDC = CreateCompatibleDC(hdcScreen);
HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, iWidth, iHeight);
HBITMAP hBmpOld = (HBITMAP)SelectObject(hDC, hBmp);
// Draw image to memory DC
img.Draw(hDC, 0, 0, iWidth, iHeight, 0, 0, iWidth, iHeight);

// Call UpdateLayeredWindow
BLENDFUNCTION blend = {0};
blend.BlendOp = AC_SRC_OVER;
blend.SourceConstantAlpha = 255;
blend.AlphaFormat = AC_SRC_ALPHA;
POINT ptPos = {0, 0};
SIZE sizeWnd = {iWidth, iHeight};
POINT ptSrc = {0, 0};
UpdateLayeredWindow(hWnd, hdcScreen, &ptPos, &sizeWnd, hDC, &ptSrc, 0, &blend, ULW_ALPHA);

SelectObject(hDC, hBmpOld);
DeleteObject(hBmp);
DeleteDC(hDC);
ReleaseDC(NULL, hdcScreen);

Because I’m using CImage, you need to include the atlimage.h header.

That’s all that is required for the basics of UpdateLayeredWindow.

NOTE: The example above does not include any error checking. That is left for the reader as an excercise.

Share

Visual C++ 2010 Beta 1 and the Windows 7 RC SDK

The Visual C++ 2010 Beta 1 release contains the Windows 7 Beta SDK. For Direct2D and DirectWrite there were some breaking changes between the beta version of the SDK and the RC version of the SDK. So if you want to use those new Direct2D and DirectWrite APIs, you definitely need the latest Windows 7 RC SDK. There are some manual steps involved in getting that to work with Visual C++ 2010. For detailed explanation please check out Using the Windows 7 RC SDK in Visual C++ 2010 Beta 1 on the Visual C++ Team Blog.

Share

Visual Studio 2010 and .NET FX 4 Beta 1 Released :)

Visual Studio 2010 Beta 1 and .NET FX 4 Beta 1 have been released and is available for download if you have an MSDN subscription. The beta 1 will be publicly released very soon. Check out http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx for more information.

Share

Preview of Upcoming Direct2D/DirectWrite Article

I’m working on a new article to be published on Codeguru. The new article will be about using Direct2D and DirectWrite on Windows 7 from C++. 

I was really impressed while playing with those new APIs. The two APIs combined are pretty powerful and allow you to easily render complicated formatted text. The screenshot below shows what the demo application that will be included with the article is capable of rendering. The code behind everything you see in the screenshot is pretty simple.

The demo will show rendering paragraphs of text with different fonts, font sizes, styles (bold, italic, underlined…), font colors, text alignment and so on. It also shows that mixing left-to-right and right-to-left text is not a problem and how to render fancy text using special typgraphic features that are present in certain fonts. Hit testing will also be included which can for example be used to embed interactive hyperlinks into DirectWrite rendered text. Click on the screenshot to see a full sized version 🙂

 

NOTE: I have no idea what the Arabic piece of text is saying, so do not blame me if it says something wrong. It’s just for demonstration purposes.

Share

Developing High DPI Aware Applications

I’m currently in the process of implementing high DPI support in one of my applications. High DPI support is getting more and more important, especially with the resolution of todays laptop screens. Most people will switch to 120 DPI or even 144 DPI instead of the default 96 DPI to make text easier to read. However, when your application is not High DPI aware, Windows Vista and Windows 7 will in certain situations scale everything for you but this will result in a blurry user interface.

Microsoft has released an interesting document describing the steps involved in developing High DPI aware applications. You can find them at the following links:

Share

Script Errors in Visual Studio 2005/2008 With Internet Explorer 8

After installation of Internet Explorer 8, some wizard in Visual Studio 2005 and 2008 might give a script error. The following wizards might be affected:

  • Add Function
  • Add Variable
  • Smart Device – New Project Creation
  • Smart Device – Add Class

Get the workaround from the Visual C++ Team Blog.

Share

Wallpaper Cycler and Windows 7

When the beta of Windows 7 was released, I obviously had to install it to test Wallpaper Cycler on it. Wallpaper Cycler started fine, so that was a good start 🙂 However, when I wanted to cycle the wallpaper on the desktop, it changed the tiling setting on the desktop properly, but the wallpaper itself was not changed, bummer 🙁

Since Windows 7 comes by default with a very basic wallpaper cycler built-in, I thought that Microsoft had maybe changed the programming interface to change the wallpaper. I started to search on the internet for information regarding this, but didn’t find anything. So, I started debugging… Read the rest of this entry »

Share

“Introduction to C++” Presentation

On Thursday 27th of November I have given my first presentation for a Microsoft event. The presentation was given during a Microsoft Community Osijek (Croatia) event. You can find more information about that community on their site. The presentation was a 45 minute “Introduction to C++”. It gave a brief overview of C++ and about the advantages of C++. It also explained how to decide when to use C++ and how to fuse the C++ and C# worlds. At the end, I gave a demo on how to call a C++ DLL from C#. Comments after the presentation were quite positive 🙂

Share

Parallel Programming in Visual C++ 2010 CTP

The CTP build of Visual C++ 2010 includes a new library to help you write native parallel code. Writing parallel code is getting more and more important with the broad availability of quad-core CPU’s at this time and the many-core CPU’s that will appear in the coming years. I will only be talking about the new concurrency library for native code. Of course, writing parallel code was already possible for a long time. However, you had to create and manage all threads by yourself and this could often be a complex task. Because of this, it requires quite a bit of time to parallelize a simple loop over multiple threads. The new native concurrency library makes this much easier. Read the rest of this entry »

Share

Binding to the most recent Visual Studio Libraries

Every version of Visual Studio comes with certain versions of Microsoft libraries, like the C runtime library, the MFC library and so on. For example, Visual Studio 2008 comes with version 9.0.21022.8 of the Microsoft C runtime library and version 9.0.21022.8 of the MFC library. Read the rest of this entry »

Share