The secret back-to-edit hotkey

June 2nd, 2011

Just a tiny trick today.

When you’re programming, you’re often…

  • typing something
  • Then you browse through the same file, look for something
  • copy something
  • And now you want to get back  to the place that you previously edited.

There’s a secret hotkey (actually a sequence) for that which works in most editors: Ctrl+Z, Ctrl+Y.

Works in Visual Studio, Word, text editors, etc.

A bit of advertising: ZeroClickSpellchecker

April 5th, 2011

I recently published a new software: ZeroClickSpellchecker. It’s basically a spell-checker which doesn’t mark errors, but auto-corrects them. At least those that can be corrected safely. (It won’t try to correct kljfhsdakljh, for example.) But quite a lot errors can be corrected, so the program works pretty well. It effectively that speeds up your typing, because you don’t have to stop and correct any more.

It’s great tool when writing e-mails. Basically I wrote it because I was fed up with typing “copmuter” again and again. If you find this (or other typos) in your own e-mails, check out my auto-correction software.

Useful function: EnableWindowsDependingOn

March 21st, 2011

One of my favorite internal functions. It helps my manage my app’s GUI. Checkboxes that cause their sub-elements to be greyed out when not checked can be easily handled by this:

bool EnableWindowsDependingOn (CWnd *pParent, DWORD DependingOnThisCheckbox, DWORD Value1, ...)
{
 va_list marker;

 bool bState = (((CButton*)pParent->GetDlgItem(DependingOnThisCheckbox))->GetCheck()!=0);

 DWORD i=Value1;
 va_start (marker, Value1);
 while (i != 0)
 {
 if (i<=0xffff)
 {
 if (pParent->GetDlgItem(i))
 pParent->GetDlgItem(i)->EnableWindow (bState);
 }
 else
 ((CWnd*)i)->EnableWindow (bState);

 i = va_arg (marker, long);
 }
 va_end (marker);

 return (bState);
}

It accepts the “this-pointer” of your CDialog and the id of the master checkbox. Then you can append any number of sub-element ids or pointers. And finally a NULL. Example:
EnableWindowsDependingOn (this, IDC_CHECK1, IDC_EDIT1, IDC_EDIT2, NULL);

This would enable the two edit boxes if the checkbox is enabled.

Win+Tab in Debugging

December 31st, 2010

Placing a breakpoint can be dangerous. In some code sections, like drawing a menu, Windows doesn’t like to be interrupted. The debugger will stop your application, but your app will remain on-screen and Alt+Tab and all other options of changing the current application are blocked.

Except, if you’re using Windows 7.

For some reason the 3d-flipping mode with Win+Tab still works. And allows you to switch to the debugger.

Devloping asp.NET websites in 3 simple steps…

December 7th, 2010

Step 1: Waste hours researching to find out how to do something trivial. (Like renaming the insert link)

Step 2: Curse Microsoft

Step 3: Throw out the MS way and program it yourself.

Repeat for every trivial issue.

There IS life on the other side…

November 24th, 2010

…of the order form. I always suspected it, but it’s interesting to be on the other side for a change.

I’m talking about being a customer for a  change. I tried to check out AISIP’s member forums and one has to pay for that. Okay, I tried. I filled in the reg.net order form, hit the submit button only to see the same form again. I double-checked my data, I looked for marks that I forget something. Nothing. Same form again. I triple-checked my data, tried another browser, another computer. Even my iPhone. Nothing worked. I contacted AISIP (three times). No reply. I contacted reg.net and got a standard mail. My reply to that mail was left unanswered.

So I want to pay, but I can’t. It’s frustrating.

Hope you’re treating your customers better than that. I know that I do, but I wonder if I should test *my* payment processor…

Visual Studio 2005: Speeding up compiles

October 19th, 2010

There’s a hidden switch in Visual Studio 2005 while doubles compile speed.

I know, it sounds ridiculous.  But I’ve tested it. It’s MUCH faster now. The switch works by enabling multi-core processing. I have no idea why Microsoft has hidden this, instead of making it a big, obvious feature.

Anyways. You can enable it by adding /MP to the “Additional options” in “Configuration properties > C/C++ > Commandline”.

(Found it at 1 and 2)

Being online in Jersey

October 12th, 2010

I didn’t expect much when I searched for an option for mobile internet access in Jersey (Channel Islands). It wasn’t really important since our B&B had WiFi. And for such a tiny country I didn’t expect much competition and thus bad service from the telcos.

Wrong. So wrong.

Mobile internet access is ridiculously cheap and easy in Jersey. In fact the only problem was finding out where they sell it (Jersey Telecom, 18 Queen Street, St Helier; Mo-Sa 9:00-17:30). I paid only £9.99 for 1GB of traffic. I wish mobile internet in the Netherlands was that cheap. 😉

And it worked just wonderful. No technical problems (like in Scotland), almost no coverage problems (as in Spain) and no trouble with the charging (as in the Netherlands). Great.

Dangerous CFile::GetStatus

October 1st, 2010

The third (and I hope final) dangerous posting.

This code looks harmless enough:

CFileStatus rStatus;
CFile::GetStatus (MyFilename, rStatus);

And it will work most of the time. But CFileStatus uses CTime, which is limited to dates after 1.1.1970. If you apply this code to a file with a file-modification date of e.g. 1.1.1960, GetStatus will raise an exception. (Which it isn’t documented to to.) And if you don’t catch that, it will terminate your program.

Dangerous printf

September 17th, 2010

It took quite some time until I found this bug. Here’s a simplified version of what caused it:

char dir[2048];
GetCurrentDirectory(2048, dir);
printf(CString("Current dir is:")+dir));

That’s doesn’t look bad, does it? And (like in the great programmer quotes), it works on my computer. But it doesn’t work if the customer’s current folder is something like “%&§something”, because it contains %s.

So don’t throw any external data at the first parameter of printf, sprintf, etc; instead put it into the following parameters.

printf(“Current dir is: %s”, dir);