Tonny (4) [Avatar] Offline
Page 337 has another problem besides the "Nothing selected" problem.

Step 2 should check if _album is not null before comparing _album.FileName to albumPath.


if((_album!=null) && (albumPath==_album.FileName) return;
eebrown (89) [Avatar] Offline
Re: Another bug in page 337

You might be right. In theory, the value of albumPath here should be non-null, since it corresponds to a required value from a combo box. This is why I didn't check it here. Still, it is always good to be defensive in your programming, so this is probably a good change.


Tonny (4) [Avatar] Offline
Re: Another bug in page 337/More problems in chapter 10.
Ehhh. Eric......

If on initial startup whatever album is on top in the combo-box can't be opened then there is no valid album loaded, allthough there is a path selected in the combo-box.
So this check is really required. I had it crash on me in it's original form the very first time I started the application. And I wasn't even trying...... Just happened to have a mal-formed .abm file at the top of the directory list, leftover from experimenting with the various load-version routines.
(By the way: I found that setting the DataSource in the constructor in stead of the OnLoad() is required for VC# 2005 too, just like in VC# 2003.)

On another point in that same chapter: Page 342, step 3 has a major flaw:
_album.CurrentPhoto.Photographer = pg;

By itself a correct statement but the program logic dictates that only the SaveSettings method updates the real photo info.
This way it is impossible to undo the change by hitting the Cancel or Reset Settings buttons, since the Validate method has already applied the permanent change.

And another thing:
If there are no photos in the album (or no album) the "Thumbnails" context menu should be fixed to normal display.
Both the MeasureItem and DrawItem methods always assume e.Index is valid, which in my experience isn't always the case when the lstPhotos has an empty list. (e.index == -1) in that case. (Or at least on my PC it is: VC# 2005 on WinXpSP2).
eebrown (89) [Avatar] Offline
Re: Another bug in page 337/More problems in chapter 10.
Ah. Well, I stand corrected (actually, I'm sitting, but you get the idea). All very good and valid points. Hopefully you are still enjoying the book dispite the bugs, or perhaps because of the bugs.....

Thanks for your thoughts and comments,