*****EXTRA EXPLANATARY TEXT TO PAGE 37, "ADDING THE APPLICATION CODE"
Read on from the initial code fragment in the book.
You will find the following text very helpful in refining the Icon Viewer Exercise
Thank You



Whenever the current drive selection is changed, this routine updates the 
Drive field in the DirectoryPicker component and adjusts the caption of the 
CurrentPath label. If you compile and run now, you'll see that the 
DrivePicker control is working properly. However, clicking the mouse around 
in the DirectoryPicker control doesn't seem to have any effect on the 
CurrentPath label. Let's fix that too.  
 
Double-click on the DirectoryPicker component. Once again, Delphi will 
create a new routine, this time called TIconViewForm.DirectoryPickerChange. 
There's only one line of code that needs to be added to this procedure, like 
this: 
 
procedure TIconViewForm.DirectoryPickerChange(Sender: TObject); 
begin 
    { Update display to reflect directory change } 
    UpdateDisplay (DirectoryPicker.Directory); 
end; 
 
OK, so what's the UpdateDisplay routine, I hear you cry! This is a routine 
that we'll write ourselves (we'll make it a separate procedure so that we 
can call it from elsewhere). First, add the following procedure declaration 
to the list of procedures in the TIconViewForm declaration. Don't add it to 
the private or public part of the class. 
 
procedure UpdateDisplay (const NewDir: String); 
 
Now add the actual procedure anywhere in the implementation part of the unit.
Here's what it should look like: 
 
procedure TIconViewForm.UpdateDisplay (const Newdir: string); 
begin 
    { Update CurrentPath's Caption with new directory pathname } 
    CurrentPath.Caption := NewDir; 
end; 
 
With these changes, clicking the mouse in the directory list box will 
properly update the CurrentPath caption but there's one last problem with 
the directory changing logic. If you use the cursor keys to change the 
selection highlight in the directory list box, you'll see that once again, 
the CurrentPath caption isn't being updated.  
 
We can easily fix this too. Select the DirectoryPicker component, switch 
over to the Events page of the Object Inspector and double-click the mouse 
to the right of the OnClick event entry. This will create another event 
handler for the DirectoryPicker, and place you at the beginning of the 
routine. Add a couple more lines of code like this: 
 
procedure TIconViewForm.DirectoryPickerClick(Sender: TObject); 
begin 
    { Update display according to current selection on DirectoryPicker } 
    UpdateDisplay (DirectoryPicker.GetItemPath(DirectoryPicker.ItemIndex)); 
end; 
 
Running the program now, you'll find that the cursor keys correctly update 
the CurrentPath caption.  
 
You can now ensure a smooth, bug-free Icon Viewer test Program. Go on to 
Use the Form Create Event !

Wrox Press
 
