Pages

Sunday, 14 January 2007

What I like in Vista

What I like in Vista:
  • the UI obviously
  • the search (however still not as fast as Google Desktop Search)
  • the audio: ability to set per-application volume, on/off status for each audio device, easy to switch between various audio drivers
  • the snipping tool
  • the backup tool. Definitely easier to use than Windows XP's. If the PC is off when a backup is scheduled, the backup takes place as soon as the PC is switched back on.
  • the performance monitor and the reliability chart: the chart goes down as the frequency of crashes increases. See my chart below for the last month.
  • Check for solutions window: when you download updates, Vista remembers the previous crashes and checks for solutions for each of them.
  • Built-in disk partioning.

  • Previous versions of a file are automatically saved (where? when? I don't know, but it's a very usefull feature, more clever than a rubbish bin).
  • Offline files. Ability to encrypt offline files.

What I don't like:

  • the backup: it does not offer you to back-up files from a specific folder. It only allows file types.

What I listened to this week #9

Tuesday, 9 January 2007

Porting unmanaged C++ code from VS2003 to VS2005

This should normally not cause too much trouble, after all, it's the same language and the same platform. Only the compiler changes a little. The VS2005 compiler does extra checks, especially in the 64bits and security area.

Warning C4244: 'initializing' : conversion from 'INT_PTR' to 'int', possible loss of data

  • Solution: disable Detect 64-bit portability issue in the project options Configuration Properties > C/C++ > General.

Warning C4996: 'sprintf' was declared deprecated

  • Solution: use the new and secure sprintf_s.

Reference: Deprecated CRT Functions

Note: don't use the new secure functions if you intend to keep compiling under VS2003. VS2003 projects will break if the new secure CRT functions are used. To disable the warnings, define _CRT_SECURE_NO_WARNINGS.

Warning C4996: 'itoa' was declared deprecated

  • Solution: replace itoa with _itoa or _itoa_s ...or use a CString (which is more elegant):

Warning C4996: '_fcvt' was declared deprecated

  • Solution: use _fcvt_s or CString.

Warning C4482: nonstandard extension used: enum 'CSecureRst::OperatorTypeEnum' used in qualified name

  • Solution: don't write the name of the enum type when specifying the enum.

Sunday, 7 January 2007

Trying Out... #1

  • Dreamweaver 8: looks very similar to past versions. Site configuration does not want to memorise the ftp username/password of my website. It is possible to select all recently modified files in one go (very usefull as an alternative to re-synchronise your whole site)
  • Ubuntu: installed Ubuntu on my old 2.8GHz PC without a single problem. One glitch: can't find a Linux driver for my WG111T WiFi adapter therefore no internet at the moment, not good.
  • Adobe Photoshop Elements 5.0: major improvement about the past versions: the pic import dialog has many more options.
  • Enterprise Library for .NET Framework 2.0 - January 2006
  • Adobe Illustrator

What I listened to this week #8

Saturday, 30 December 2006

Mixing legacy MFC code with Windows Forms (Part 3)

Summary: The ability to intimately mix unmanaged MFC/C++ code with managed code is one of my favorite features in .NET. Migration projects that would otherwise take years can be done in a matter of months. To re-use legacy MFC/C++ code with minimal changes and call the code from a C# Winforms application, you need to:
  1. Create an MFC DLL project and activate the /CLR switch to indicate that this is a mixed assembly.
  2. Add the legacy source files to the MFC DLL project.
  3. Prepare the legacy code so that it compiles for Unicode (see Converting an MFC project to Unicode)
  4. Add a managed class to the above project. This class will be the interface between the managed Winforms application and the legacy MFC/C++ code.

Project settings:

  • Dynamically link against the MFC DLLs: in Configuration Properties > General > Use of MFC
  • Compile for Unicode (this is mandatory because .NET works only with Unicode): General > Character Set
  • Make it a mixed assembly: General > Common Language Runtime Support, set to /CLR. This way the DLL can contain both unmanaged and managed code. The managed code will be visible to any managed application using the DLL.

Can I debug the legacy MFC/C++ code loaded as part of the managed application?

Yes! In the project properties for the managed executable using the DLL, go to the Debug tab and tick Enable unmanaged code debugging.

Step by step:

  1. Create an MFC DLL using the MFC DLL Wizard. Call the project Legacy for instance. Options: Regular DLL using MFC DLL. If the legacy code is an MFC-based MDI application, the main frame will be created as soon as the DLL is loaded (through CLegacyApp::InitInstance)
  2. Add the source files containing the legacy code to this new project.
  3. Set the project settings as described above.
  4. Compile and fix all Unicode issues and other compiler annoyances...
  5. Created a LegacyWrapper C++ class.

Issues associated with compiling with /CLR:

  • Warning LNK4248: unresolved typeref token (01000013) for '_TREEITEM'; image may not run. Solution here. This is because _TREEITEM is defined in a native library, but the forward declaration is done in an MSIL module. Forcing the definition of _TREEITEM in stdafx.h eliminates the warning.

Cool things in Visual Studio 2005

Useful features that do not exist in Visual Studio 2003

  • Code definition window (separate window that shows automatically the definition of the variable currently under the cursor)
  • Find all references command
  • Class view is searchable
  • Class view shows base types and derived types (C++)
  • Class view contains a subpane showing members of current class (makes the tree cleaner)
  • Find in files dialog is modeless (crucial for refactoring) and automatically moves to display the matched string.

New in Visual Studio 2005: http://msdn2.microsoft.com/en-us/library/88fx1xy0(VS.80).aspx