Ok, everyone is blogging these days right? Now my Xbox 360 has started a blog too. It will keep you posted about my 360 usage 24-7 so stay tuned!
July 2006 Archives
Ok, so I'm a coder. Does that mean I type fast? I dunno, you decide. I found this site that test your typing speed and here's my result:
Found Glend Fiedlers excellent articles on physics and networked physics. Don't forget to read them.
I've started playing with "Unit Testing". I use UnitTest++ as my unit testing framework after reading the excellent Unit Testing framework evaluation by Noel Llopis, I figured he must know what features you need, and I'm very happy with the framework so far.
Anyway, when I'm setting up a project for unit testing I've found I'm most comfortable with the following setup:
In the MyApplication project I put everything related to the actual application this could be a GUI application like an MFC app, then there's alot of code that's not the actual logic. In this project I link to my Libraries implementing the logic. In this case MyLibrary1. Then I have MyTestApplication that is the standalone application that is actually doing the unit testing. This application links with the UnitTest++ library and also the libraries implementing the logic, again, in this example, it's MyLibrary1.lib.
Now, the purpose of this post was to point out one of the more important details here. In MyTestApplication I have configured it to run the application itself as a Post-Build Event, like this:
This runs the application after a successful build and outputs any failed tests as clickable errors. This is the ultimate cool, never forget this! It will produce output similar to this:
In the MyApplication project I put everything related to the actual application this could be a GUI application like an MFC app, then there's alot of code that's not the actual logic. In this project I link to my Libraries implementing the logic. In this case MyLibrary1. Then I have MyTestApplication that is the standalone application that is actually doing the unit testing. This application links with the UnitTest++ library and also the libraries implementing the logic, again, in this example, it's MyLibrary1.lib.
Now, the purpose of this post was to point out one of the more important details here. In MyTestApplication I have configured it to run the application itself as a Post-Build Event, like this:
This runs the application after a successful build and outputs any failed tests as clickable errors. This is the ultimate cool, never forget this! It will produce output similar to this:
Sometimes I don't understand what they do over there in Redmond. No, I'm not one of those that hate microsoft, quite the opposite. But still, they continue to do surprise me from time to time. Consider this sample MFC application:
This is what I get from the MFC app wizard in Visual Studio .Net 2005. I have created a Doc/View app and selected CFormView as my initial view and I've added a few sample controls to the view. Is this what you expect from your $10.000+ IDE in 2006? I guess not, read on.
Let's see what we need to do to our MFC application in order to spice it up. The problem here is that in order to get that nice XP look you'll have to use the common controls dll version 6. If you look in your stdafx.h file you should have the following lines when using .Net 2005:
[cpp]
// Allow use of features specific to IE 6.0 or later.
// Change this to the appropriate value to target other versions of IE.
#ifndef _WIN32_IE
#define _WIN32_IE 0x0600
#endif
[/cpp]
This might fool you to think it allows you to use features specific to IE 6.0 or later. But the seasoned programmer that Microsoft targets knows this isn't enough. In Windows XP or later you need a manifest to tell what version of common controls dll to use. This is a simple 3-step process for an MFC application.
1. First we add this line to resource.h
[cpp]
#define IDR_MANIFEST 1
[/cpp]
2. Then add the following to your .rc2 file (MyApp.rc2)
[cpp]
IDR_MANIFEST RT_MANIFEST MOVEABLE PURE
"res\\MyApp.manifest"
[/cpp]
3. The last step is to add the actual manifest file. Create a new textfile in your favorite text editor paste the following. Don't forget to change MyApp to your applications name. Then save it as "MyApp.manifest" in your projects "res" folder.
[xml]
MyApp
[/xml]
Rebuild your application and find your MFC application has suddenly changed skin:
This wasn't very hard, right? Why didn't Microsoft add this to appwiz generated applications? Maybe they would argue that they don't know what version of common controls dll you are targeting, but a simple check that _WIN32_IE is 0x600 would solve that. I really don't know what they are doing over there in Redmond, but I'd expect they atleast document this functionality. Sigh.
This is what I get from the MFC app wizard in Visual Studio .Net 2005. I have created a Doc/View app and selected CFormView as my initial view and I've added a few sample controls to the view. Is this what you expect from your $10.000+ IDE in 2006? I guess not, read on.
Let's see what we need to do to our MFC application in order to spice it up. The problem here is that in order to get that nice XP look you'll have to use the common controls dll version 6. If you look in your stdafx.h file you should have the following lines when using .Net 2005:
[cpp]
// Allow use of features specific to IE 6.0 or later.
// Change this to the appropriate value to target other versions of IE.
#ifndef _WIN32_IE
#define _WIN32_IE 0x0600
#endif
[/cpp]
This might fool you to think it allows you to use features specific to IE 6.0 or later. But the seasoned programmer that Microsoft targets knows this isn't enough. In Windows XP or later you need a manifest to tell what version of common controls dll to use. This is a simple 3-step process for an MFC application.
1. First we add this line to resource.h
[cpp]
#define IDR_MANIFEST 1
[/cpp]
2. Then add the following to your .rc2 file (MyApp.rc2)
[cpp]
IDR_MANIFEST RT_MANIFEST MOVEABLE PURE
"res\\MyApp.manifest"
[/cpp]
3. The last step is to add the actual manifest file. Create a new textfile in your favorite text editor paste the following. Don't forget to change MyApp to your applications name. Then save it as "MyApp.manifest" in your projects "res" folder.
[xml]
This wasn't very hard, right? Why didn't Microsoft add this to appwiz generated applications? Maybe they would argue that they don't know what version of common controls dll you are targeting, but a simple check that _WIN32_IE is 0x600 would solve that. I really don't know what they are doing over there in Redmond, but I'd expect they atleast document this functionality. Sigh.
I've started using IrfanView for creating screenshots. I was already using IrfanView for displaying images in Windows but I was looking for a tool to easily create screendumps without starting Photoshop that is a bit too heavy for this purpose. I read somewhere that you could paste and crop in some Microsoft Photo editor and immediately thought that it must be possible to do similar in IrfanView and Presto! It was. The only annoying detail is that it's a bit hard to crop, but I usually do alt-print-scrn anyway so it's not to much of a problem.
I just do "Create New (empty) image..." and then paste my image into that. It adjusts to fit automagically. Nice!
After receiving the message below when trying to debug a simple application I ran out of patience with this Beta. The problem with Microsoft is that they always suggest a solution that never work. Very frustrating.
Found some good reads on GUI development in Vista:
Windows Vista User Experience Guidelines
What's new in Vista
Top 10 Ways to Light Up Your Windows Vista Apps
Forums: Software Development for Windows Vista
The million dollar question is how you use all this fancy stuff from C++. I guess you can't?
Yup, upgrading CuteFTP 5.0 XP to CuteFTP Pro 7.0 fixed the problems I had with CuteFTP.
Here's the problem I had with 5.0:
Even though I have successfully connected to an ftp site the panes that should show local and remote directories are just plain empty, which is not what we want.
Here's what the working 7.0 looks like:
Even though I have successfully connected to an ftp site the panes that should show local and remote directories are just plain empty, which is not what we want.
Here's what the working 7.0 looks like:
I think it's a bit annoying when you keep updating software for decades but you never stop to think about if actual features needs updating or fixing. One good example of this is InstallShield. I've been using InstallShield for a very long time and for an a la carté of versions. But the thing is, the only thing that seem to change between versions is the look and feel of the IDE. Even in the latest version (11.5 or is it 12) there are alot of silly things that was a problem back in version 6 too. Windows also has some of these issues, look at this software you get with Windows Vista:
Why don't they add atleast one feature to paint for every new version of Windows? Then paint would be useful by now.
Visual Studio .Net follows the same pattern, Resource Editor anyone? But that rant deserves it's own post!
Why don't they add atleast one feature to paint for every new version of Windows? Then paint would be useful by now.
Visual Studio .Net follows the same pattern, Resource Editor anyone? But that rant deserves it's own post!
While doing the installer marathon I thought I might aswell install Office 2007 Beta since I got that question some hundred times on my trip to installing Vista. So here's what Word 2007 looks like. Quite a big difference! No more menus.
I couldn't resist the opportunity to use these words as example!
I couldn't resist the opportunity to use these words as example!
Oh yes! I also fell for the temptation to try out the coming Windows since every Microsoft page I visit mentions this and that from Vista along with juicy screenshots. I'm not a chicken, so I wiped my entire C partition and installed a fresh Vista on there. Now, was that a wise decision? We'll see, I'll keep you posted.
Here are a couple of annoying things to begin with:
Here are a couple of annoying things to begin with:
- Daemon tools doesn't seem to work (investigating)
- CuteFTP 5.0 that I've been using for a long time didn't work (new version bought)
- Total Commander had problems (working beta installed)
- Application Data folders and such are locked (hacked around)
I'm moving all my arcade related material over to www.arcadesoul.com.
Finally! As you can hopefully see below I'm now able to post proper code snippets as I've installed the great iG: Syntax Hiliter Plugin for my wordpress blog. I find it very frustrating that it's hard to post proper code in a modern publishing system. But I don't have that problem any more! Yay!
I think you should be able to post good looking code in the comments too! Unfortunately I can't show exactly how to insert code tags because then the example would be code. But you do [cpp] for c++ and then you must close the code section with the same tag but with a slash that you do with normal html.
A friend of mine asked me how to replace a string with some other string in stl. How hard can it be? I immediately got a bad feeling in the stomack, remembering struggeling with this problem myself before. It's hard to try to persuade people to use stl when such simple matters don't have a clean solution with stl. I finally found something similar to this in a usenet post. It's about as clean as I can come up with. Any ideas?
[cpp]
#include "string"
#include "algorithm"
#include "iostream"
/*****************************************************************************/
static void Replace( std::string& source,
const std::string& find,
const std::string& replacement)
{
size_t len = find.length();
std::string::size_type pos = 0;
while( (pos = source.find( find, pos )) != std::string::npos )
{
source.replace( pos, len, replacement );
}
}
int main()
{
std::string Source =
"I once_had a dog named Harry and a dog named Noodles";
std::string FindStr = "dog";
std::string ReplaceStr = "cat";
std::cout < < Source < < std::endl;
Replace( Source, FindStr, ReplaceStr);
std::cout < < Source < < std::endl;
return 0;
}
[/cpp]
Yay! Today I finally beat New Super Mario Bros!
Gaming doesn't get much better than this. The new DS Lite must be the best console I've ever had period. And the games on the DS platform is more fun than any other games on any format. Ok.. Haven't had time to try Loco Roco yet, but I don't think it'll beat Mario Bros. I'm having a bit of a difficulty deciding if this was better than Partners in Time though.