Taking a shortcut

September 1st, 2010

A simple trick to make work a bit easier. Whenever you have folder with a few files and you often need to run a certain program or change to another folder afterward working with the files, create a Windows shortcut in this folder.

Example:

The Easy2Sync for Outlook configuration files are in this folder. Whenever I have to mess with them (delete them for a clean-start-test , for example) I will usually want to run Easy2Sync for Outlook afterwards. That’s why I created a shortcut to the program in this folder.

Simple and yet helpful.

Dangerous COleDateTime::ParseDateTime

August 20th, 2010

COleDateTime::ParseDateTime is a handy function to parse a date string into a COleDateTime (and then SYSTEMTIME and then CTime).

The problem is that the expected date format depends on the user’s system settings. If you’re parsing a string that is always in the same format (from a file or from the internet), then parsing might work on your computer, but fail on the customer’s computer (in another country).

Solution: Use the locale ID parameter to force the parsing language.

CMap: Mapping CString to CStringArray

August 9th, 2010

Just a simple MFC trick. To map from CString to CStringArray use:

CMap<CString, LPCTSTR, CStringArrayX, CStringArrayX&>

where CStringArrayX is defined as:

class CStringArrayX : public CStringArray
{
 public:
 CStringArrayX() {}
 CStringArrayX(const CStringArrayX &qSource);
 CStringArrayX &operator = (const CStringArrayX &qSource);
};
CStringArrayX::CStringArrayX (const CStringArrayX &qSource)
{
 SetSize (qSource.GetSize());

 for (long c=qSource.GetSize()-1; c>=0; c--)
   (*this)[c]=qSource[c];
}
CStringArrayX &CStringArrayX::operator = (const CStringArrayX &qSource)
{
 SetSize (qSource.GetSize());
 for (long c=qSource.GetSize()-1; c>=0; c--)
   (*this)[c]=qSource[c];
 return (*this);
}

Hopefully this post keeps some people from searching as long as I did… 😉

Silencing command line builds

August 2nd, 2010

My builds have become more and more complex. Especially when releasing a new version it wasn’t always easy to tell at first glance whether all build steps succeeded. Some tools (I’m not telling names, here) are quite verbose and “pollute” the build log with things that I don’t really care about.

Here’s a simple freeware tool that I wrote to fix this: SilentCommandline.exe. It works as a DOS pipe with filter functions that can be configured in two external text files.

Using SilentCommandline:

Simply append it to your build batch files:

yourbuildcommand.exe |SilentCommandline.exe

It will take all output of  yourbuildcommand.exe, check if you want to see it and print it to stdout. To configure what you want to see, create 2 text files in the same folder where you keep SilentComandline.exe and name them silentlines.txt and silentlinesre.txt.

Config files:

The first one is simple. On string per line. If one of the strings equals a line from your build output, then this line will not be printed. You can use that for static texts that are always the same. Example:

Succeeded

The second file works basically the same, but allows you to use regular expressions in each line. Use it to handle build outputs that might change. Example:

Protected[0-9]* blocks of [0-9]* blocks total.

Download:

Here’s the download link to SilentCommandLine.exe

System requirements: Windows

Linking .lib files in C++

July 22nd, 2010

Sooner or later you will need to link static external library files (.lib files), when developing a larger project. Microsoft C++ can do this in several ways:

  1. Link settings in the project properties
  2. Adding the file to the source file tree
  3. Using a #pragma

So far I’ve mostly used 1 & 2, because they’re the easiest and most obvious ways. Solution 2 can even be used conditionally for certain build types (by using the “exclude for this build” option).

But with the projects getting more complex, I found that solution 3 is the best and switched projects to that. The reason is that different combinations of project types (debug/release 32/64 Bit) are otherwise quite difficult  to handle.

With #pragma’s is does take some space in one your .cpp-files, but at least the different conditions are easy to understand and verify:

#ifdef _WIN64
  #ifdef _DEBUG
    #pragma comment(lib, "C:\MyPath\\MyDebug64.lib")
  #else
    #pragma comment(lib, "C:\MyPath\\MyRelease64.lib")
  #endif
#else
  #ifdef _DEBUG
    #pragma comment(lib, "C:\MyPath\\MyDebug32.lib")
  #else
    #pragma comment(lib, "C:\MyPath\\MyRelease32.lib")
  #endif
#endif


The C++ riddle

June 24th, 2010

C++ is sometimes even more cryptic than regular expressions. Can you figure out what this one means?

%016I64lx

Next > Weiter > Siguiente >

April 10th, 2010

When doing screenshots of your software you may face some problems with the buttons in wizard and property sheet dialogs. The buttons at the bottom of these dialogs are drawn by Windows, with the language of your Windows installation. That can differ from the language of your application. The result doesn’t look professional. An English dialog with (for example) German “Zurück” / “Weiter” buttons (instead of Back / Next) won’t impress the customers.

You should of course correct this with an imaging application. And to make this easier I made a collection of the usual wizard buttons to copy/paste in

  • English, German and Spanish
  • Enabled, Disabled, Highlighted
  • NT, XP, Win7 Style

Feel free to use them.

Download WizardButtons_Devblog.png (33k)

Using yoursite.com/nice_links for promotions

March 29th, 2010

When doing a promotion or sending links by e-mail, it’s nicer to have short, speaking links like yoursite.com/discount instead of the normal link monsters. You might implement this on your server as folder name (polluting your folder structure) or use the htaccess file (where a mistake can kill the entire server).

But I suggest a simpler solution: Use a 404 error page script.

Most hosting companies allow you to specify a custom 404 (“not found”) error page. This page can also be a script. And the script can check if the requested URL is your promotion code and then redirect to your real page.

This can also keep you from typing (or writing on paper) long product URLs. I have set up shortcuts for all my products. If I want someone to have the link of the 1-Click Duplicate Delete for Outlook page, I can simply write this link:
easy2sync.com/1cddo
Instead of:
http://www.easy2sync.com/en/produkte/1-Click-Duplicate-Delete-Outlook.php
(Which is so long that some mail clients print into 2 lines, effectively breaking it.)

Here’s the PHP script for that:

<?php
if (getenv("REQUEST_URI")=='/1cddo')
{
 header ('Location: http://www.easy2sync.com/en/produkte/...
 exit;
}
?>
<html><head><title>Error!....

Tree development

March 23rd, 2010

No, not talking about trees in the terms of computer science this time. Real ones. This blog is taking part in my “a blog, a tree” project. Just by blogging about this and using this button, a tree gets planted for this blog:
My blog has planted a pine tree.

If you have a blog, you’re invited to take part, too. No cost for you, I’m paying the bill here. So, if you’re having a feeling that you should do something for the environment, join it and get your blog a tree: A blog, a tree

Amazing customer feedback…

March 15th, 2010

For one of my projects I have implement a system that handles crashes, reports technical details to me and asks the customer “which program function (hotkey or name in the menu) did you just use?

So far, the answers to this question have often been amazingly useless. For example one customer just wrote: “CRASHED AGAIN! no obvious reason…“. The data shows however that the customer was right in the middle of importing a project.

Yeah, no obvious reason. Customers are only humans, I guess. And some of them more than others…