Learning to Unplug

It’s the last day of the year for me. I won’t be writing any new blog entries in until next year. Rebecca and I take each Christmas off and don’t come back until after Epiphany, which is the actual 12th day of Christmas (just in case you were wondering about the songs that use it). If you send me an e-mail, I won’t respond until January 9th-the first work day after Epiphany. I completely unplug while on vacation and you should too. Here are the top reasons I unplug during my down timeperhaps you’ll find a reason that works for you.

  • Rebuilding Our Marriage: Anyone who knows me, knows that I’m devoted to my wife. I consider my marriage far more important than any other element of my life here on earth. Rebecca patiently waits for me the rest of the year, but vacations are devoted to her and our marriage. I look forward to our time together and count the days until we can spend time doing something interesting together.
  • Focus on Family, Friends, and Neighbors: My family has always been good about working around my schedule. There are times during the year where I simply tell them that a book deadline is far too important to visit with them and they understand. My closest friends and even my neighbors are equally cognizant of my need to work. I try to make up for the lack of attention during the rest of the year with visits throughout vacation.
  • Personal Health: I want to provide my readers with the best service that I can. That means taking care of my personal health: spiritual, mental, and physical. Disconnecting from everything gives me time for self-reflection and helps me to grow as a person. It also provides me with much needed rest. No one can do a job well unless they have received the proper rest and nourishment.
  • Organizing Personal Finances: Believe it or not it is never too early to sort out your retirement plans. I have been doing lots of research into retirement planning on websites like Key Advice and have decided that I might release some equity from our home to fund my retirement. In case you were not aware, equity release is a way for homeowners aged 55 and over to release tax-free funds from their homes without having to move. It is an increasingly popular way for people approaching retirement age to boost their finances. This makes it one of many finance options in retirement for those who are looking to make a retirement plan. In fact, a friend of mine recently decided to release some equity from his home so I must remember to ask him for some advice about what to do. Apparently, nowadays you can even use an equity release calculator to work out how much money you might be entitled to claim. Naturally, I am very interested to see how much money I might be able to claim from my own property. Furthermore, although no one likes to think too much about no longer being around, I have also established who I want to take on the responsibility of lasting power of attorney over my estate. After talking to a solicitor and writing a will, I found some brilliant estate planning resources online that explained how to establish an LPA. You can take a look here if you would like to learn more: https://willstrustslpa.co.uk/serviceareas/lasting-power-of-attorney-online/.
  • Personal Projects: It seems as if too many people wait until retirement to work on anything fun. I’m not planning to wait. During vacation, I take time to work on personal projectsthings I want to do for the sheer pleasure of doing them. I’m pretty sure that I’m not going to retire anytime soon, unless an injury or some other unforeseen issue makes retirement necessary. So, I plan to do a few of these projects while I’m still able to do them. Vacation provides the opportunity.


During this holiday season, whatever your beliefs or wherever you live, I hope that you take time to unplug. Do something interesting, exciting, spiritual, or simply satisfying. The world of work will still be here when you get backyou’re truly not indispensable. It may seem as if the world will come down around your ears if you disconnect, but that’s a lie. I’ve been doing it for many years now and nothing terrible has happened. I have no cell phone, no computer access, no connectivity of any kind to impede my efforts to relax and recharge.

Rebecca and I will spend the next two weeks putting puzzles together, baking cookies, working on crafts, and sitting by the wood stove reading. We’ll spend part of the holiday in church, addressing our spiritual needs. Yes, there will even be some movie watching on our television, but that’s going to take second place to getting reacquainted after months of hard work writing, gardening, and generally making a living. Of course, I’ll need a little exercise after my lack of restraint in holiday eating (I hope my doctor doesn’t see this), so I’ll do a little wood cutting too. I’m sure that we’ll spend plenty of time with family, friends, and neighbors as well. See you next year!

Many Hands Make Light Work

I’m not sure who first came out with this bit of wisdom, but it’s true. Dividing a task amongst many people does make the work a lot lighter. You get the task done a lot faster for a number of reasons, some obvious, some not. Of course, with multiple people doing the work, the task is completed faster and with less effort from each individual. The people working on the task can encourage each other and a gentle gibe can prompt less motivated individuals to work a bit harder. However, I’m not talking about a team here. Teams are organized and often rely on one really skilled person to carry other less skilled people along. What I’m talking about is a group of individuals, with relatively the same ability, getting together to accomplish a task without the usual trappings of the team environment. There truly is a difference.

I was reminded of this difference when I read the post of my friend Bill Bridges, entitled, “The Good Cheer Drive.” It’s precisely this sort of example that I’m thinking about when it comes to the expression, “Many hands make light work.” These people came together and in a dizzying array of disorganization managed to get food together for those who are less fortunate and need a bit of a helping hand during the holidays. There is no concept of team (and the associated ego) here—simply a group of people getting together for the common good. It sounds like my sort of event.

Self-sufficiency sometimes requires a touch of this sort of environment as well. Whenever I can, I try to get someone to help when I go into the woods. To do otherwise would be foolish. When I’m cutting wood, I fell old trees that no one is using (no animals or helpful insects have made the tree a home). The trees sometimes do unexpected things, especially when the crown is caught in the branches of another tree. If someone is there helping, they can at least go for help should a tree decide to fall on me. There is safety in numbers.

Trying to wrestle a large trunk is also quite an experience. It doesn’t take much tree to produce enough wood that it’s nearly impossible for even a well-muscled man to move it about. Since I don’t use any sort of heavy equipment, I have to rely on careful cutting techniques and the help of others to move some of these large trunks around. Most of the time, the time in the woods is spent with others who enjoy being out there as much as I do. We’re a group of individuals working together to get the wood down from the hill without disturbing other trees in the safest manner possible.

This year I’ve been relying on the help provided by a new friend, Cody. He’s been out at least once a week (and often twice) to help me get my wood in for winter. As a result, for the first time ever, I have almost all of the wood I need for the winter already stacked, and it isn’t even Christmas yet. Even Rebecca has been able to get out to help a little this year, so a number of us are involved in getting the wood done up. Many hands do indeed make for light work.

WoodCutting

When you start your self-sufficiency effort, consider the need to help other people and to ask others to help you as needed. Yes, you do need to do as much as you can, but when there would be an immense risk in doing the work by yourself, look for those individuals who are willing to help. Make sure they get something out of it too. Exchange labor as you would exchange products (see my Sharing and Swapping Food post for details). The most important gift you can get out of the exchange is a friend you can rely on and believe me, they’re scarce in today’s world.

How do you work with others? Have you ever contributed toward a group effort of the kind I explore in this post? Let me know at John@JohnMuellerBooks.com.

 

Are Enforced Updates a Good Idea?

I currently have a system running Windows 98 in my home because there are some older games and other applications that I still enjoy using on that platform. The system isn’t connected to the Internet or any other machine because I consider the system a security hazard. I’ve set this system up for the sheer pleasure of seeing some of my old applications come to life again and to make use of some older hardware that still works just fine. The system has our movie database on it and a few other non-business items. However, the fact remains that this system would be unsafe to use to browse the Internet. It would probably be infected to the point of being unusable in a matter of hours (if it lasted that long).

Generally, when it comes to my Internet-connected systems, I use the latest software available to keep my systems secure. The software isn’t allowed to languish until it reaches an unprotected state either. I test every available update on one machine. If it works and I don’t see any major problems, I deploy it to all of the other systems I own on the same day. One of the major ways to keep your systems safe is to ensure you’re running the latest version of the software—the one with all of the latest bug fixes.

For most developers, debugging is an ongoing process. Although it seems is if it would be possible to squash every bug in the application after one carefully conducted review, the reality is that most applications are complex enough that even a team of developers can’t find every bug in multiple reviews, much less one. It also doesn’t help that many companies rush products to market long before they’re ready because they need to generate money from that product in order to remain solvent. So, from a certain perspective, we’re all beta testers and those bug updates are a requirement if we want to keep our systems running properly in the hostile environment of the Internet.

Unfortunately, not everyone is as conscientious as I am and some people are downright suspicious of updates. So, I can understand
Microsoft’s perspective about employing forced updates of some of their
products when those products are attached to an unfriendly Internet.
Just in case you haven’t heard it, Microsoft is going to start automatically updating Internet Explorer users. However, Microsoft is hardly the first one to the party with enforced updates. A lot of other vendors use this tactic as well. Many products today include a forced update feature. Most allow the user to opt out of the forced update, but the default setup relies on forced updates to keep less skilled user’s machines updated.

There are many advantages to using forced updates. The most important is that using forced updates keeps everyone on the Internet safer. The fewer machines that nefarious individuals can exploit, the better. Forced updates also reduce vendor support calls and could therefore help keep software costs lower. Using forced updates can also improve the user experience and make users more productive. For all these reasons, and more, I see forced updates as a big win for the less experienced user, especially the home user who is currently susceptible to every sort of virus and intrusion out there.

However, there is a down side to using forced updates. All users find them intrusive. Even if the update is silent, it uses resources during the update process. As a result, the user’s system suddenly slows down, which could actually cause some number of support calls when the update process is a resource hog. Forced updates are also a cause for concern in corporate environments where running untested software can cause a host of interoperability problems with custom software. Expert users also find forced updates a problem because the update can (and usually will) cause problems with the user’s custom configuration.

I’d also like to see forced updates provide a wait feature. Some users will apply unauthorized fixes to repair a bug until an update comes out. These unauthorized fixes tend to cause problems with the update. Giving the user a chance to remove the unauthorized fix before the update occurs will keep the update from actually trashing the user’s system. Personally, I never use these unauthorized fixes simply because they do have such a huge potential for causing more problems than they fix. However, some users don’t have the option to wait for the update to come out and must rely on an unauthorized fix.

So, what is your opinion about forced updates?  Are they a good idea? Generally, I see them as a win for novice and home users, but less helpful to corporate and expert users. Let me know your opinion at John@JohnMuellerBooks.com.

 

Improving the GrabAPicture Application (Part 1)

If you haven’t read about the GrabAPicture application yet, you really need to do so before we embark on the update described in the upcoming series of posts. You can find a list of these posts using a simple search. The GrabAPicture application covers a lot of ground and shows how to perform a wide range of tasks using VB.NET. You’ll have to read the posts to see everything it does, but you’ll gain an understanding of working at the command line, working with Windows API using P/Invoke, and creating a solution that has both command line interface and GUI. You’ll even see how to create a shortcut to ask GrabAPicture to perform tasks automatically.

It isn’t often that I can even demonstrate a program this large in a book, so this series of entries has given me a chance to do something a little different. Being able to interact with some of you while I’ve been writing the posts has also been a new experience. So, this series of blog entries has been interesting for me too and I plan to do others in the future. The next application might rely on C#, but whatever language it uses, it’ll be interesting.

As capable as GrabAPicture is, it has some limitations that you might want to address. That’s the purpose of the series of posts that follow. Now, you can extend GrabAPicture in any number of desirable ways, but let’s start with these ideas:

 

  • Add configuration options to the command line.
  • Make it possible to configure wallpaper to use the new Windows 7 settings.
  • Add a browse button to the main form.
  • Provide a snapshot of the highlighted image.


These ideas would make a good starting point, but I’m open to any ideas you might have. If you’ve had a chance to play with the application a bit, you’ve probably noticed some deficiencies. I can’t guarantee I’ll correct them all, but I’ll give every deficiency you note some thought to determine whether a fix is doable. Let me know what you’d like to see as additions at John@JohnMuellerBooks.com. You can find the next post in this series at Improving the GrabAPicture Application (Part 2).

The e-Book in Your Future

Back in February I wrote a post entitled, “Paper or e-Book?” where I stated a personal preference of using paper for fiction books and e-books for anything technical. I expanded on that post by writing about the advantages and disadvantages of online media when compared to technical books in my “Is the Technical Book Dead?” post. I even considered the effects of electronic media on libraries in my “Future of Libraries?” post. Let’s just say I’ve given this topic a lot of thought, but up until now, facts have been a little hard to come by. Most people speculate about e-books, but they can’t truly back up their speculation with hard facts of the sort that just about anyone can accept. However, I’ve been seeing articles such as, “Ebook Sales Both Rise and Fall in Wiley’s Divisions” (by Mercy Pilkington) as of late.

It seems as if I’m not the only one who finds the convenience of e-books addicting when it comes to technical topics. However, according to this article (probably the best of the batch I found online), the sales of e-books are stratified. Someone is less likely to buy a cookbook in e-book form, than a tome on writing your first application in C#.

My take on everything I’m seeing is one of practicality. A technical book in e-book form is convenient. You can pack entire bookshelves in an incredibly small form factor. Even the least expensive Kindle can pack 1,400 books in a tiny form factor. You can read all of your books anywhere you go and modern screens have become better at presenting information under a range of conditions, as long as you can focus on the e-book, rather than the surrounding environment.

I also see e-books becoming status-quo in the classroom. In addition to being able to store a hoard of books in an incredibly small space, schools will find book updates far easier to provide and less expensive as well. The media options provided by e-books will enhance the learning experience. From what I’ve seen, e-books are already becoming well established in the school system and I see a day coming soon where a student won’t touch a paper book as part of the educational process.

However, e-books are less useful in some situations. If you spill a sauce on your paper cookbook, you wipe it off and continue on as if nothing happened. Spilling the same sauce on your Kindle will have disastrous results as the sauce oozes into the device and damages it. Even a cheap Kindle costs $79.00 (at last look), which makes for a mighty expensive sauce.

I can also see problems using a Kindle for woodworking. For one thing, the print is small enough that it would be really hard to read construction instructions while using a Kindle. Not only that, but imagine trying to use a drawing in the Kindle—good luck. In addition, dust specs from the woodworking environment would eventually end up inside the device. I haven’t met an environment yet that wood dust can’t penetrate.

It’s hardly surprising then that e-books have become quite popular in some areas, but not in others. The debate is over though. Sometime in your future you’ll likely find yourself using an e-book for a practical need. The more time I spend researching the topic though, the less likely I find it that paper books will go away anytime soon. Paper is still quite practical for many needs and people will use something that’s both inexpensive and practical. Not many people are into gizmos for the sake of having them.

That brings me to my latest project. For the first time I’m writing a book that’s designed from the ground up for the electronic environment. The book is entitled, “Java eLearning Kit for Dummies” and the more I work on it, the more fascinated I become with the possibilities that this book provides. You’ll receive a CD with this book that contains a fully interactive environment. In fact, for the first time ever, you’ll be able to engage in one of my books without bothering with the paper content. You’ll gain access to the book’s information by interacting with the content on the CD. The entire concept is amazing and I’m having a great time working on it.  I’ll let you know more details when the book gets closer to release, but for now, it’s something to think about as you look over the book offerings online. Expect to see more books of this sort.

What is your take on e-books? What niche do you see e-books filling? Do you see yourself using e-books in the future (why or why not)? Talk to me about your expectations for e-books at John@JohnMuellerBooks.com.

 

Christmas Remembrances

The firelight,
Eye’s delight,
Rest upon a pudding made with plum.

Holiday cheer,
Christmas is near,
Putting smiles on faces glum.

Mistletoe,
Love will grow,
In hearts dressed for love.

A tree bright,
Lights delight,
An angel peers down from above.

Cookies sweet,
What a treat,
When served with beverages festive.

Fire’s warming,
Friends charming,
With nary a soul that’s restive.

Choirs sing,
Bells that ring,
A service of children’s design.

Christ is near,
Source of cheer,
In a manger of another time.

Copyright 2011, John Paul Mueller

 

Mind Boggling Questions in C++

I constantly tell readers they need to view my books as a starting point, rather than the end of their education on a particular subject. This sentiment holds true for C++ All-In-One Desk Reference For Dummies as it does for all of my books. When you read this book, you get a really good start with C++. By the time you’re finished, you can create some useful applications and you know enough about the CodeBlocks IDE to use it effectively. Fortunately, there are many places online to expand when it comes to C++ and I ran across one of them today in an article entitled, “Amusing C++.” The title, more than anything else, caught my attention. What, after all, could be amusing about C++?

This is one of those sorts of articles I wish I had thought to write myself. The author, Vasily Starostin, has a unique perspective about C++ and some of the issues you could face when working with it. More importantly, he uncovers some interesting compatibility issues between compilers, all the while having fun with the C++ language.

These sorts of mind boggling questions force even professional developers to think about the language and how it works. It may seem as if a language specification is solid, but then you see that there are gaps in how the specification is put together and that there is room in the standards for unique vendor implementations. Working with unique implementations can lead to innovation, but it can also lead to all sorts of compatibility issues when you need to move your application from one product to another.

After you’ve completed reading my book, make sure you continue on with online resources. Of course, the place that you should look first for issues related to this book (and some general interest C++ topics) is the C++ All-in-One for Dummies category on this blog. It’s a shame that this particular Dummies book doesn’t include the Parts of Tens feature that is found in other Dummies books. However, here are ten places you can look for C++ materials and examples:

Where do you get additional information about C++? What sorts of information do you look for on these sites? Let me know at John@JohnMuellerBooks.com.

 

Flying Squirrel Antics

This is the time of year that I spend a good deal of time in the woods cutting fallen trees as fodder for my wood stove. Not only is cutting wood good exercise and a cost effective way to heat our home, but using wood can be better for the environment because it’s a renewable resource. We do our best to replace the trees that we use to heat our home. In fact, some areas of the woods that we initially began using 15 years ago are already growing back quite nicely.

Some people get the idea that I keep my nose to the grindstone while out there, which would be a true waste. For one thing, not paying attention to what’s going on around you is a really good way to get hit by a falling tree. They all have to fall sometime—there isn’t any unwritten rule that states they’ll wait until I’m no longer around to hit. However, the thing I like best about being in the woods is seeing all of the animal life. You might think that Wisconsin in the winter is a dead place, but life abounds in all its forms. So, it was with a great deal of glee that I watched flying squirrels glide between trees the other day.

It’s a common misconception that flying squirrels actually fly. They’re fantastic gliders, not fliers. A flap of skin between the front and back legs provides lift for them to glide between trees quite swiftly. In fact, of all the squirrels, I think they move the fastest (we also have red and gray squirrels around here). Trying to grab a picture of them is a near impossibility. I’m sure someone has done it, but they’re more skilled than I am .

I haven’t seen much of Woody, the pileated woodpecker this year. He often watches me work on trees. I can differentiate this particular woodpecker from the others in our woods in two ways. First, the bands of colors on Woody’s head are different from other woodpeckers in our woods. Second, he has a habit of looking at me sideways with the right eye. I’m not sure if his left eye is damaged or it’s simply a characteristic of this particular woodpecker. What attracted Woody is unknown to me. Most woodpeckers want nothing to do with me (granted, Woody does keep his distance and isn’t in any way tame).

Of course, there are always rabbits, endless assortments of birds, and all sorts of other animals in the woods. Sometimes I’ll see opossum. On one occasion I saw a fishersomething that is extremely rare from what I’ve been told. The fisher seemed to be chasing after rabbits, but it was far enough away that I don’t know what it was chasing with absolute certainty. On rare days I’ll see a deer, but because I make so much noise cutting wood, such sightings are incredibly rare for me. I’m most likely to see a deer on days when I go to the woods for the sheer joy of observing nature, rather than cutting wood.

Some people question why I’d go to the woods to sit on a tree stump in the middle of winter when I could be inside safe and warm. Nature offers considerable entertainment for anyone willing to take the time to view it. During this particular day, the antics of the flying squirrels had me chucking quite hardily. You just don’t get that sort of entertainment on television. Do you ever observe nature and all it has to offer? What are your favorite sights? Let me know at John@JohnMuellerBooks.com.

 

Exploring the GrabAPicture Application (Part 12)

We’re finally down to the last baseline post for the GrabAPicture application, frmAddEdit, which is the chameleon form. The Exploring the GrabAPicture Application (Part 11) post describes how the frmConfigure code modifies the appearance of the code for this form so it can perform several tasks. At the center of this capability are several versions of the constructor that allow for different configuration techniques as shown in the following code.

Public Sub New()
   MyBase.New()
 
   'This call is required by the Windows Form Designer.
   InitializeComponent()
 
   'Add any initialization after the InitializeComponent() call
 
End Sub
 
Public Sub New(ByVal Title As String)
   MyBase.New()
 
   'This call is required by the Windows Form Designer.
   InitializeComponent()
 
   'Change the title.
   Me.Text = Title
End Sub
 
Public Sub New(ByVal Title As String, _
               ByVal AddButtonTitle As String)
   MyBase.New()
 
   'This call is required by the Windows Form Designer.
   InitializeComponent()
 
   'Change the title.
   Me.Text = Title
 
   ' Change the add/edit button title.
   btnAddEdit.Text = AddButtonTitle
End Sub
 
Public Sub New(ByVal Title As String, _
               ByVal AddButtonTitle As String, _
               ByVal RemoteEdit As Boolean)
   MyBase.New()
 
   ' This call is required by the Windows Form Designer.
   InitializeComponent()
 
   ' Change the title.
   Me.Text = Title
 
   ' Change the add/edit button title.
   btnAddEdit.Text = AddButtonTitle
 
   ' Remove the directory button and resize the
   ' location field as needed.
   If RemoteEdit Then
      btnGetResource.Visible = False
      btnGetResource.Enabled = False
      txtLocation.Size = txtName.Size
      _IsRemote = True
   End If
End Sub

As you can see, each of the constructors provides one more level of configuration. You might wonder why the application doesn’t simply use the most configurable of the four constructors, but this approach has some disadvantages.

 

  • Using just a single, complex constructor makes the application inflexible.
  • The developer would also need to provide the default values for title, button, and remote editing capability, even if these values didn’t change from the default dialog box.
  • Adding this requirement would make the application more susceptible to errors.
  • Using four different constructors also forces the developer to consider which entries actually do need to change. Giving someone the opportunity to think application design through is never a bad idea.

Notice that the fourth constructor contains special code for removing the browse button from view when working with a remote resource. The browse button wouldn’t do the user much good in this case and clicking it can only cause problems.

Using the custom constructors is really important in this case and makes the application much stronger. You can divide the rest of the code for this form into three areas:

 


  • Property creation and maintenance

  • Form loading

  • User controls

Most of the code for this form is straightforward, albeit a bit convoluted at time due to the form’s multipurpose nature. The following sections describe each of the coding areas.

Property Creation and Maintenance

This form is used in a number of ways, so it’s important that the application be able to track the form’s current state. Otherwise, the application could make an assumption about the form content that isn’t correct. The best way to provide state information outside of the form is to use properties. Relying on properties makes it possible to monitor and control interaction with form state information in a controlled way. The application uses the properties shown here.

' Private variables used for editing purposes.
Private _Resources As LocalUri()
Private _RemoteSources As RemoteUri()
Private _IsRemote As Boolean = False
Private _IsEdit As Boolean = False
Private _RecordNumber As Int32 = 0
 
' Tracks the current list of local resources.
Public Property Resources() As LocalUri()
   Get
      Return _Resources
   End Get
   Set(ByVal Value As LocalUri())
      _Resources = Value
   End Set
End Property
 
' Tracks the current list of remote resources
Public Property RemoteSources() As RemoteUri()
   Get
      Return _RemoteSources
   End Get
   Set(ByVal Value As RemoteUri())
      _RemoteSources = Value
   End Set
End Property
 
' Shows whether edit is for a local or remote resource.
Public ReadOnly Property IsRemote() As Boolean
   Get
      Return _IsRemote
   End Get
End Property
 
' Determines whether this is an add or edit action.
Public Property IsEdit() As Boolean
   Get
      Return _IsEdit
   End Get
   Set(ByVal Value As Boolean)
      _IsEdit = Value
   End Set
End Property
 
' Defines the edited record.
Public Property RecordNumber() As Int32
   Get
      Return _RecordNumber
   End Get
   Set(ByVal Value As Int32)
      ' Verify the input is positive.
      If Value >= 0 Then
 
         ' Perform separate checks for local and remote.
         If _IsRemote Then
 
            ' Verify the input is less than the number of
            ' records when using a remote resource. This
            ' check will also throw a null reference
            ' exception if the record source isn't
            ' properly initialized.
            If Value >= _RemoteSources.Length Then
 
               Throw New ArgumentOutOfRangeException( _
                  "Record Number", _
                  "Record number is too high.")
            End If
         Else
 
            ' Verify the input is less than the number of
            ' records when using a local resource. This
            ' check will also throw a null reference
            ' exception if the record source isn't
            ' properly initialized.
            If Value >= _Resources.Length Then
 
               Throw New ArgumentOutOfRangeException( _
                  "Record Number", _
                  "Local record number is too high.")
            End If
         End If
 
         ' Set the record number.
         _RecordNumber = Value
      Else
         Throw New ArgumentOutOfRangeException( _
            "Record Number", _
            "Provide a positive record number.")
      End If
   End Set
End Property

The properties are pretty straightforward. They serve the following purposes:

 


  • Resources: Defines a local URI.

  • RemoteSources: Defines a remote URI.

  • IsRemote: A read-only property that the application can use to determine whether to access the Resources or RemoteSources property for the current URI.
  • IsEdit: Controls whether the dialog box provides an adding or editing appearance. The adding dialog box is blank, while the editing dialog box contains the current local or remote record information.
  • RecordNumber: Contains the record number of the current local or remote source.

Form Loading

Form loading is important because the code in this area controls the initial appearance of the dialog box. A form used for adding a new record, whether local or remote, is always blank, so it doesn’t require any custom configuration. However, if the form is used to edit a current record, the form loading code must detect whether the form is editing a local or remote resource. In addition to URI differences, local resources have an additional button available for browsing the local hard drive. The following code shows how form loading works.

Private Sub frmAddEdit_Load(ByVal sender As Object, _
                            ByVal e As System.EventArgs) _
                         Handles MyBase.Load
   ' Set the form up for editing.
   If _IsEdit Then
      ' Make sure you use the correct database.
      If _IsRemote Then
         txtName.Text = _RemoteSources(_RecordNumber).Name
         txtLocation.Text = _RemoteSources(_RecordNumber).Location
         Select Case _RemoteSources(_RecordNumber).Style
            Case Styles.Stretched
               rbStretched.Checked = True
               rbCentered.Checked = False
               rbTiled.Checked = False
            Case Styles.Centered
               rbStretched.Checked = False
               rbCentered.Checked = True
               rbTiled.Checked = False
            Case Styles.Tiled
               rbStretched.Checked = False
               rbCentered.Checked = False
               rbTiled.Checked = True
         End Select
      Else
         txtName.Text = _Resources(_RecordNumber).Name
         txtLocation.Text = _Resources(_RecordNumber).Location
         Select Case _Resources(_RecordNumber).Style
            Case Styles.Stretched
               rbStretched.Checked = True
               rbCentered.Checked = False
               rbTiled.Checked = False
            Case Styles.Centered
               rbStretched.Checked = False
               rbCentered.Checked = True
               rbTiled.Checked = False
            Case Styles.Tiled
               rbStretched.Checked = False
               rbCentered.Checked = False
               rbTiled.Checked = True
         End Select
      End If
   End If
End Sub

As you can see, the first thing the code detect is whether the form is using for adding. If it is, then the application doesn’t do any configuration.

When the dialog box is used for editing, the application checks the status of _IsRemote to determine how to configure the dialog box. The code obtains the correct record and then displays the information on screen.

User Controls

There are three user controls, but you only need to provide code for two of them (btnCancel provides the default action when clicked). The Add/Edit button (btnAddEdit) is always visible. The relies on it to make any changes permanent. The browse button (btnGetResource) is only available when working with a local resource. The user relies on this button to locate resources on the local hard drive. The following code shows how these buttons work.

Private Sub btnAddEdit_Click(ByVal sender As System.Object, _
                             ByVal e As System.EventArgs) _
                          Handles btnAddEdit.Click
   If IsEdit Then
      If _IsRemote Then
         ' Change the array data.
         _RemoteSources(_RecordNumber).Name = txtName.Text
         _RemoteSources(_RecordNumber).Location = txtLocation.Text
         If rbStretched.Checked Then
            _RemoteSources(_RecordNumber).Style = Styles.Stretched
         End If
         If rbCentered.Checked Then
            _RemoteSources(_RecordNumber).Style = Styles.Centered
         End If
         If rbTiled.Checked Then
            _RemoteSources(_RecordNumber).Style = Styles.Tiled
         End If
      Else
         ' Change the array data.
         _Resources(_RecordNumber).Name = txtName.Text
         _Resources(_RecordNumber).Location = txtLocation.Text
         If rbStretched.Checked Then
            _Resources(_RecordNumber).Style = Styles.Stretched
         End If
         If rbCentered.Checked Then
            _Resources(_RecordNumber).Style = Styles.Centered
         End If
         If rbTiled.Checked Then
            _Resources(_RecordNumber).Style = Styles.Tiled
         End If
      End If
   Else
      If _IsRemote Then
         ' Add a new array element.
         If _RemoteSources Is Nothing Then
            ReDim _RemoteSources(0)
         Else
            ReDim Preserve _RemoteSources(_RemoteSources.Length)
         End If
 
         ' Instantiate a new array item.
         _RemoteSources(_RemoteSources.Length - 1) = New RemoteUri
 
         ' Add the data to the array.
         _RemoteSources(_RemoteSources.Length - 1).Name = txtName.Text
         _RemoteSources(_RemoteSources.Length - 1).Location = txtLocation.Text
         If rbStretched.Checked Then
            _RemoteSources(_RemoteSources.Length - 1).Style = Styles.Stretched
         End If
         If rbCentered.Checked Then
            _RemoteSources(_RemoteSources.Length - 1).Style = Styles.Centered
         End If
         If rbTiled.Checked Then
            _RemoteSources(_RemoteSources.Length - 1).Style = Styles.Tiled
         End If
      Else
         ' Add a new array element.
         If _Resources Is Nothing Then
            ReDim _Resources(0)
         Else
            ReDim Preserve _Resources(_Resources.Length)
         End If
 
         ' Instantiate a new array item.
         _Resources(_Resources.Length - 1) = New LocalUri
 
         ' Add the data to the array.
         _Resources(_Resources.Length - 1).Name = txtName.Text
         _Resources(_Resources.Length - 1).Location = txtLocation.Text
         If rbStretched.Checked Then
            _Resources(_Resources.Length - 1).Style = Styles.Stretched
         End If
         If rbCentered.Checked Then
            _Resources(_Resources.Length - 1).Style = Styles.Centered
         End If
         If rbTiled.Checked Then
            _Resources(_Resources.Length - 1).Style = Styles.Tiled
         End If
      End If
   End If
End Sub
 
Private Sub btnGetResource_Click(ByVal sender As System.Object, _
                                 ByVal e As System.EventArgs) _
                              Handles btnGetResource.Click
   If OFD.ShowDialog() = DialogResult.OK Then
      txtLocation.Text = OFD.FileName
   End If
End Sub

Let’s discuss the simple button first. When the user clicks the browse button, the application displays an OpenFileDialog control, OFD. If the user selects a file and clicks OK, the code places the name of the file into txtLocation.Text. Theoretically, a little customization would make this dialog box friendlier, but it works well as presented.

The btnAddEdit_Click() event handler is a little more complex. It actually performs one of four actions depending on the dialog box options.

 

  • Edit/Remote: The code changes the record information found in _RemoteSources for the current record pointed at by _RecordNumber.
  • Edit/Local: The code changes the record information found in _Resources for the current record pointed at by _RecordNumber.
  • Add/Remote: The code either creates a new _RemoteSources array or adds an element to the existing _RemoteSources array. In both cases, the code adds the new record to the end of the array. Note that because the array is zero-based, you must subtract 1 from the array length in order to find the last record of the new array.
  • Add/Local: The
    code either creates a new _Resources array or adds an element to
    the existing _Resources array. In both cases, the code adds the new
    record to the end of the array.

Well, now you have the full story on the base application—the application I started with. The next post will discuss some of the additions we’ll pursue in the new year. For now, please keep those comments coming. Let me know if you have any questions at all about this form at John@JohnMuellerBooks.com.

 

Windows 8 and the App Store

In case you haven’t heard, Windows 8 will have an App Store when it appears on the scene. The overall review of the App Store is mixed. Microsoft Watch has the best write-up regarding the marketing angle for the App Store. Microsoft is definitely doing everything it can to attract developer attention, including offering a sweet deal on revenue sharing. Mary-Jo Foley has a different perspective and brings up the point that the App Store may offer private stores that businesses can use to distribute in-house applications. I find that using the App Store for this purpose strangely compelling because it offers the user a way to get applications that’s familiar. John Dvorak, on the other hand, has sounded the alarm about the closed system that Microsoft and Apple seem to be developing. It may very well be that Microsoft’s and Apple’s motives aren’t altruistic, but John also brings out a number of positives for the App Store as well. All of these, and many other, articles bring out important points about the App Store. Reading them will help you understand what the App Store is all about. Of course, you’ll want to remain mindful that these posts are all coming before the beta is even on the street (expect to see it in February 2012).

While others are concerned mainly with the needs of users and businesses, my main concern is for the developer. In Considering the New Metro Interface—Ribbon Redux? I consider the issue of the closing architecture on the developer. Microsoft has created an environment where the developer will need to tread an increasingly fine line in order to create and distribute acceptable applications. As I read the various articles about the App Store, I have to wonder whether this new form of distribution will completely stifle innovation. After all, Microsoft will become the guardian of the gate that determines whether an application is successful.

Experienced developers will face an increasingly steep learning curve with Windows 8. Not only is there the Ribbon and the Metro interface to deal with, but now developers will need to discover new ways to market their application. Microsoft hasn’t yet said that developers must use the App Store, but the writing is on the wall and smart developers will make the move sooner than later. While some of my books, such as RibbonX for Dummies, address the Ribbon and books such as Professional Windows 7 Development Guide describe the latest techniques for creating Windows applications, none of my books (nor those of other authors) are preparing developers for the reality of the triple whammy of Ribbon, Metro interface, and App Store.

Supposedly Microsoft is already creating a wealth of applications for the App Store with the help of vendors who are on Microsoft’s short list of the faithful. If you’re interested in hearing more about the App Store, you can find a special Windows Store for Developers blog that will hopefully address the many concerns that you must have. Windows 8 is not yet closed, so developers can continue creating desktop applications that are sold in stores or online, but the days of the desktop application appear numbered. If the App Store and Metro interface pan out as Microsoft hopes they will, developers should begin writing for these environments sooner than later.

Of course, I’ll continue to write books that will address your needs. Any updates of my current books will include tips on working with the Metro interface and show how to get your application listed in the App Store. In the meantime, I’d like to hear from you. What are your concerns about the direction in which Microsoft is moving? What do you need from me in the way of help to create applications for this new environment? Contact me with your questions and concerns at John@JohnMuellerBooks.com.