Weird problem with AfxWinMain()

January 27th, 2010

I spent the last hours hunting down a weird crash problem in AfxWinMain(). It’s the init function in an MFC application that gets called before anything else.

And it crashes at “if (!pThread->InitInstance())” because AfxGetThread() returned a NULL pointer.

The problem was paired with link errors that vanished when the buid was repeated. Since this is “normal” with MS C++ (I’ve seen that problem often before), I didn’t really notice it.

As it turns out the entire code was correct. I imported it into a new project and it worked. Comparing the the vcproj-Files I found the line that made all the difference. Removing this line suddenly fixed my problem:

“ObjectFile=”.\DebugD64″

(in Configuration > Tool Name=”VCCLCompilerTool”).

Strange AdWords status problems

January 14th, 2010

Okay, so I finally found a way of contacting AdWords. I had problems with two new ads. One has been under review for more than a week, another was approved, but had zero impressions.

For both cases, I got a meaningless standard text, explaining their policy.  And both times the ad suddenly worked. So, something was definitely broken and is now fixed, but Google doesn’t even bother to say so…

Awkward help from GoogleAdwords

January 11th, 2010

Google’s always amazing when it comes to finding the right pages. I wanted to contact then, so I searched the official German Adwords Help for “Kontakt”.

Places 8+9 were:

If you don’t speak German: unmöglich=impossible. You get the rest, I think…

So, the AdWords help was helpful for me, too. I gave up contacting them. Less money for Google…

JavaScript MessageBeep

December 15th, 2009

For quite some time I tried to find something like MessageBeep in JavaScript to attract the user’s attention for a change on the screen. JavaScript doesn’t have anything similar.

But I found a small flash player called niftyplayer that can play mp3 sounds, stay invisible and be controlled from javascript. To get the MessageBeep effect, simply install the player, set width and height to 0 and call niftyplayer(‘niftyPlayer1’).play();

(Thanks to pragma for pointing me in the right direction.)

Using Google to protect your site

November 29th, 2009

Is your website error free?

My site  has grown over the years and uses a lot of PHP code. It’s difficult to test each and every aspect of it. Here are 3 simple tricks that can help you test your website. They don’t replace a real test (that you should do after a each change), but they’re a nice addition.

Trick 1:

Use Google to search your website for “error” or “warning”. You can use the format:
site:yourdomain.com (warning or error )

This of course has a terrible lag, since Google crawls your website only every few days or weeks, but on the other hand Google may use different parameters or aspects that you use in your own tests.

The real fun comes with combination of trick 2.

Trick 2:

Use Google alerts to automatically search your website for problems. You can create a free Google alerts account and use the search mentioned above to have Google automatically check your site every day. If something breaks, Google will send you an e-mail.

Trick 3:

Same as above, but use your Google to watch your site for hacked pages. A hacker might have exploited a weakness in your server and created a new page for whatever product he promotes with his spam mails. You probably don’t want to become involved with this. So instead of using “warning or error” in the search. use a list of the usual phrases and medical products that the spam mails usually contain.

It’s a one-time work of a few minutes. The rest of the work is done automatically by Google and can save you a lot of trouble.

Using usertype.dat as spell checker

November 15th, 2009

There are thousands of classes, structure, functions and constants in the Windows library and it’s often hard to remember the right spelling. Here’s a simple trick to use the usertype.dat as a very simple spell checker.

Usertype.dat?
First, usertype.dat is a file which can be configured in the MS IDE (see help file, because it differs with the versions). Simply activate it and use my usertype.dat as a start. It contains almost 4000 key words from the libraries.

When you now type one of these key words right, it will be displayed in a different color (I prefer gray – to emphasize that I don’t have to pay attention here). Here’s how it can look like.

Example:

Note that all the common things like HICON, LoadImage or LR_DEFAULTCOLOR are written in gray because they’re spelled correct. And other words (variables in this case) like hIcon and IconId1 a printed in white because they’re not predefined. If I had written Load_Image (instead of LoadImage), it would have been printed in white, too, and I know that it might be incorrect.

A website navigation mistake

October 21st, 2009

I’m currently thinking about buying a new computer and came across Dell’s website. Here’s the menu that they presented to me to choose from:

Don’t know about you, but I was completely lost here. Would I want a Studio or and XPS computer? No idea. Probably the folks at Dell know their products too well and sometimes forget how it must look like for their (first-time) customers.

I left Dell’s website (without bothering to ‘learn’ what they mean) and revisited my own site to see if I did it any better. And was surprised to see that I made the same mistake  (a bit) with the product names.

Some of my product names (like 1-Click Duplicate Delete for Outlook) are pretty clear. Others (like ReplyButler) can leave you guessing. A customer might be interested in it, but only if I make it easy for him to understand what the product is for.

So here’s the way I found to make it clearer:

It’s still very brief, but at least tells you enough about it to decide whether you might be interested or not.

Being online in Great Britain

September 6th, 2009

We visited Scotland this year and having my own little business, having access to the internet was important to me.

It was a lot easier than expected. Very many Hotels and B&Bs have WiFi nowadays – a lot more than in Ireland two years ago. So it was easy to go online with my laptop. Except for the B&B that had WEP2, which my (old) laptop doesn’t support.

Just for the heck of it, I also wanted to have internet access with my cell phone – that however was quite difficult.

The mobile company “Three” seemed to offer good rates for prepaid connections. I had researched that before. However, they don’t sell them at the store. The vendor guy send us to the O2 store next door.

Okay, O2 *does* sell them. But they are terribly complicated. I purchased a SIM card for 10 GBP here (without having to register it to my name, surprisingly). But the internet access didn’t work. I had to activate it with a scratch card. Then (as I found out with my laptop and WiFi next day) I had to book a “bolt-on” with a special SMS (“web” to 21300) and wait almost 48 hours as O2 took its sweet time processing it. Then (with another internet research) I had to correct the APN (payandgo.o2.co.uk / vertigo / password) which the SIM provides wrong by default. And then it finally worked. However, I’m only allowed to use it on my cell phone, now with the laptop…

Now I only have to remember to cancel the “bolt-on” (SMS “web off” to 21300) before I return home….

Dangerous QuickSort

May 15th, 2009

When it comes to sorting, QuickSort is an all-time-favourite (so I though) and I chose it for implementing a sortable list with data. In some cases (when there were on few changes), it didn’t perform well, to I switched to an old-fashioned bubble-sort in such cases.

What I had to learn now, is that if the data that has to be sorted, is arranged in the right / unfortunate way, then QuickSort can easily crash your program by consuming excessively stack space and finally causing a stack overflow. You won’t need much data for this. 10,000 items is enough to perform terribly slow and finally crashing the software.

I switched to IntroSort, which seams to work better (so far) and (according to Wikipedia) behaves better in worst-scenarios than QuickSort. We’ll see. Sample implementations for IntroSort are rare, but I found one linked in this blog.

Don’t force me to reboot on updates… (Windows XP)

March 1st, 2009

I just experienced a kind of terribly bad ideas part II for software design.

Microsoft has rolled out a new update. It’s  great that it was downloaded automatically. It would certainly have been nice if Microsoft had ASKED me for permission before installing it.

And it would have been VERY nice  if Microsoft would just have accepted that Ihad better things to do than to reboot my computer right now. That stupid messages comes every few minutes. Now, what part of NO don’t you understand?

The inevitable thing happened. I was away from the PC for a few minutes, couldn’t click on the “no” button and the computer rebooted. I can only assume it, but I doubt that the reboot process would have stopped if I had any unsaved data. (Because Opera told me on start-up that it hadn’t been closed normally.) Data loss by design. Great idea, Microsoft!

Now here’s the fix. You can download this reg-file and double-click it. It will insert 2 keys into your registry and should protect you against this very bad default behaviour.