Exploring the GrabAPicture Application (Part 3)

In the previous post, Exploring the GrabAPicture Application (Part 2), you created frmMain, the first form that the user sees when using GrabAPicture in GUI mode. Someone wrote in to tell me that I forgot to include the form settings in the table. I looked back and found they’re correct, so here’s the settings you need for frmMain:

Control Property Value
Form1 (Name) frmMain
  AcceptButton bntOK
  CancelButton btnCancel
  FormBorderStyle FixedDialog
  Size 328, 269
  Text GrabAPicture

The form also sports an Icon property setting that I’ll discuss in a separate post for all three forms. Notice that the form uses the FixedDialog style, which is something you should consider for any form like this one that doesn’t include re-sizable elements. To make the form keyboard friendly, make sure you always include the AcceptButton and CancelButton settings so that the form reacts as expected when the user presses Enter or Escape.

On to the frmConfigure form. This form contains the list of local and remote settings. I had originally thought about creating just one list. However, there are times where a person works without an Internet connection or would prefer to use Internet sources for the desktop wallpaper than local sources. A local source is one that the user can access through a local drive or a network connection, while a remote source requires a URL for access. The URL can be anything that the .NET Framework can process, including the output from a Web service as long as that output is an image. You can’t use an entire Web page as a source because the Web page would contain non-graphic elements, but you can access a particular image on the Web page. Here’s how the form appears in the designer.

GrabAPicture0301

As you can see, there are separate sets of controls for local and remote sources. The following table tells how to configure these controls.

Control Property Value
Form2 (Name) frmConfigure
  CancelButton btnCancel
  FormBorderStyle FixedDialog
  ShownInTaskbar False
  Size 425, 301
  Text Configure a Random Source
Button1 (Name) btnCancel
  DialogResult Cancel
  Location 336, 8
  Modifiers Friend
  Size 75, 23
  TabIndex 0
  Text Cl&ose
Label1 (Name) lblLocal
  Location 8, 8
  Modifiers Friend
  Size 100, 23
  TabIndex 1
  Text Local So&urces:
ListBox1 (Name) lstLocal
  Location 8, 32
  Modifiers Friend
  Size 232, 95
  TabIndex 2
Button2 (Name) btnLAdd
  Location 240, 32
  Modifiers Friend
  Size 75, 23
  TabIndex 3
  Text &Add
Button3 (Name) btnLEdit
  Location 240, 56
  Modifiers Friend
  Size 75, 23
  TabIndex 4
  Text &Edit
Button4 (Name) btnLDelete
  Location 240, 80
  Modifiers Friend
  Size 75, 23
  TabIndex 5
  Text De&lete
Button5 (Name) btnLSelect
  Location 240, 104
  Modifiers Friend
  Size 75, 23
  TabIndex 6
  Text &Select
Label2 (Name) lblRemote
  Location 8, 144
  Modifiers Friend
  Size 100, 23
  TabIndex 7
  Text &Remote Sources
ListBox2 (Name) lstRemote
  Location 8, 160
  Modifiers Friend
  Size 232, 95
  TabIndex 8
Button6 (Name) btnRAdd
  Location 240, 160
  Modifiers Friend
  Size 75, 23
  TabIndex 9
  Text A&dd
Button7 (Name) btnREdit
  Location 240, 184
  Modifiers Friend
  Size 75, 23
  TabIndex 10
  Text Ed&it
Button8 (Name) btnRDelete
  Location 240, 208
  Modifiers Friend
  Size 75, 23
  TabIndex 11
  Text Dele&te
Button9 (Name) btnRSelect
  Location 240, 232
  Modifiers Friend
  Size 75, 23
  TabIndex 12
  Text Sele&ct

In this case, the form doesn’t include an AcceptButton entry because there isn’t any default accept action available. One alternative would be to make the AcceptButton entry the same as the CancelButton entry.

Notice that this form isn’t displayed in the Taskbar. The ShownInTaskbar setting is set to False. You only want to display the main form in the Taskbar to avoid confusing the user.

The third, and final form, is a multiuse form. The application uses frmAddEdit in four different ways, but could potentially use it in other ways:

 

  • Add a Local Entry
  • Edit a Local Entry
  • Add a Remote Entry
  • Edit a Remote Entry

There isn’t any way to predict which task the user will perform most often, so the form uses the Add a Local Entry task as the focus for the controls. The calling form, frmConfigure, will change the frmAddEdit as needed to meet a specific need. The basic form looks like this.

GrabAPicture0302

This form has a few extras on it that you’ll learn more about when you write the code. For example, the ellipses (…) button only appears for local resources. It works with an OpenFileDialog control that isn’t shown on the form to help a user find a local resource on a local drive or the network. The following table contains the settings for this form.

Control Property Value
Form3 (Name) frmAddEdit
  AcceptButton btnAddEdit
  CancelButton btnCancel
  FormBorderStyle FixedDialog
  ShownInTaskbar False
  Size 300, 266
  Text Add Local Resource
Button1 (Name) btnAddEdit
  DialogResult OK
  Location 208, 8
  Modifiers Friend
  Size 75, 23
  TabIndex 0
  Text &Add
Button2 (Name) btnCancel
  DialogResult Cancel
  Location 208, 40
  Modifiers Friend
  Size 75, 23
  TabIndex 1
  Text &Cancel
Label1 (Name) lblName
  Location 8, 8
  Modifiers Friend
  Size 100, 23
  TabIndex 2
  Text &Name
TextBox1 (Name) txtName
  Location 8, 32
  Modifiers Friend
  Size 184, 20
  TabIndex 3
Label2 (Name) lblLocation
  Location 8, 64
  Modifiers Friend
  Size 100, 23
  TabIndex 4
  Text &Location
TextBox2 (Name) txtLocation
  Location 8, 88
  Modifiers Friend
  Size 160, 20
  TabIndex 5
Button3 (Name) btnGetResource
  Location 168, 88
  Modifiers Friend
  Size 24, 23
  TabIndex 6
  Text
GroupBox1 (Name) grpStyleSelect
  Location 8, 128
  Modifiers Friend
  Size 192, 100
  TabIndex 7
  Text Style Selection
RadioButton1 (Name) rbStretched
  Checked True
  Location 16, 24
  Modifiers Friend
  Size 104, 24
  TabIndex 0
  TabStop True
  Text &Stretched
RadioButton2 (Name) rbCentered
  Location 16, 48
  Modifiers Friend
  Size 104, 24
  TabIndex 1
  TabStop True
  Text &Centered
RadioButton3 (Name) rbTiled
  Location 16, 72
  Modifiers Friend
  Size 104, 24
  TabIndex 2
  TabStop True
  Text &Tiled
OpenFileDialog1 (Name) OFD
  Filter BMP Files|*.BMP|JPG Files|*.JPG|GIF Files|*.GIF|PNG Files|*.PNG|All Graphics Files|*.BMP;*.JPG;*.GIF;*.PNG
  Modifiers Friend

Notice that this form can have an AcceptButton and a CancelButton setting because there are default actions for both. As with frmConfigure, frmAddEdit doesn’t appear in the Taskbar.

Some people are thrown by the use of the GroupBox control in this part of the example. The Location property is relative to the location within the GroupBox when working with the three RadioButton controls. Likewise, the TabIndex is local to the GroupBox, so the numbering starts over with 0. There are several ways to determine whether the RadioButton is a tab stop. You can choose to set the GroupBox as the tab stop, the default RadioButton as the tab stop, or all of the RadioButton controls as potential tab stops. This example takes the last action, but you should try all three forms to see what you like best. The GroupBox also lacks a hot key because you’ll never select it directly—the focus is on the controls within the GroupBox, so that’s where the hot keys are.

The next installment will begin by discussing the icon used for this example. It’s nothing fancy, but there are some tricks you need to know about when working with icons. Let me know if you have any questions at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the GrabAPicture Application (Part 4).

 

Interacting with the Task Scheduler Service

The Task Scheduler service has become an essential part of Windows. With that in mind, Microsoft has made a change in the way this service works. You can no longer stop it and the service automatically starts when you start Windows. The idea is to ensure that the service is available to meet Windows needs. The change quietly occurred during a Vista update and is automatically part of Windows 7. Consequently, when you try to interact with the service, you get an error message of [SC] OpenService FAILED 5: Access is denied. To see this for yourself, try typing SC Config Schedule Start= Demand and pressing Enter on an update Vista or any Windows 7 system.

The reason I mention this particular issue is that on page 43 of Windows Command-Line Administration Instant Reference, you see instructions for interacting with the Task Scheduler service. You can still query the service and perform some other tasks with it, but you can’t stop it or configure the method used to start it. When you look at this service using the Services console of the Administrative Tools folder, you see that you can’t even change how the service starts as shown here (everything is grayed out).

TaskScheduler01

There are a number of other services that fall into this same category. You can’t stop, start, or reconfigure them. Here is a list of the most common services that you can’t control using the SC utility (you can still query all of them):

  • DCOM Server Process Launcher
  • Group Policy Client
  • Plug and Play
  • Remote Procedure Call (RPC)
  • RPC Endpoint Mapper

Microsoft hasn’t documented the reason why you can’t configure any of these services. However, the reason that Microsoft has made it impossible to change the Task Scheduler service is that Windows 7 uses it extensively. For example, a number of applications rely on the Task Scheduler:

  • System Restore
  • Reliability History
  • Windows Update
  • Other Program Updates

In addition, Windows 7 uses Task Scheduler to perform a number of checks. These checks affect system reliability and stability:

  • TCP/IP Conflicts
  • Disk Diagnosis
  • Network Information
  • System Sound Service
  • Power Controls
  • WinSAT

Even so, you may find that you need to stop the service for some reason. The common technique that you’ll find for overcoming this problem is to perform the task from the registry. Open RegEdit and locate the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule key. The Start value controls how the Task Scheduler starts. Double click this value and change the entry to 4 as shown here to disable the service, or 3 to set it to manual.

TaskScheduler02

Reboot the system. You still won’t be able to make any changes using the SC utility or the GUI, but the status of the service will change to either disabled or manual as you requested. When the service is in manual mode, you can start it manually. Change the Start value back to 2 to re-enable the service. The problem with changing these services is that you don’t know how the change will affect system stability. This is a change at your own risk scenario. Please let me know if you have any questions at John@JohnMuellerBooks.com.

Is Privacy a Right?

One of the readers of C# Design and Development took me to task some time ago for not discussion the matter of security in my book. He has been the only reader to ever ask me about the issue of privacy, so I didn’t think too much about it at the time. When I wrote the book, I thought it far more important to discuss security—keeping the data, application, and user safe. In fact, the book makes security part of an application triad the developer must consider during the design process. My thinking at the time was that privacy is a matter settled by management as part of a policy that is often implemented outside the developer’s control. To a certain extent that perception is still valid, but I’ve since learned that the developer does bear some responsibility toward the user when it comes to privacy.

A recent ComputerWorld article has made me think yet again about the whole issue of privacy. In this case, OnStar is collecting absolutely every last bit of information they can about you, without your permission, and selling it to anyone with a few pennies to spend. (A later article says that OnStar is reversing course on this decision.) They do tell you about spying on you, but you’ll only find this information if you read through the legalese contained in the Terms & Conditions. However, there are some people who don’t think you have any right to privacy in the first place. Industry leaders that include Facebook chief Executive, Mark Zuckerberg, Google chief, Eric Schmidt, Sun Microsystems chief, Scott McNealy, and Oracle chief, Larry Ellison would prefer you not to have any privacy whatsoever. They’d simply love to dig into every aspect of your life. The use of newer technologies, such as super cookies, have also proven that companies have a strong desire to invade your privacy.

So, the developer is faced with a number of questions when it comes to privacy. The most important of which is whether privacy is a right. According to the ComputerWorld article, the senate has finally woken up and decided that perhaps privacy is a matter they really should consider, especially when it comes to such brazen violations such as the one by OnStar. There is some validity to the belief that the Constitution and Bill of Rights offers at least some protection of privacy. Some laws, such as the Health Insurance Portability and Accountability Act (HIPAA) add additional rights. However, I imagine that we’ll experience years of delays, political wrangling, and legal interpretation before those rights are specifically spelled out in a way that developers (and others) can understand.

Assuming that a certain level of privacy is a right and that it’s legally protected, the developer still has a host of questions to answer. Here are some of the things you should think about as a developer when designing an application.

  • What is the company policy regarding privacy?
  • How does an application specifically guard or expose a user’s privacy?
  • When does a user’s right to privacy override the desire of management to invade it?
  • Which rights does a user forfeit as a member of an organization?
  • Is privacy configurable as an opt in or an opt out selection?
  • Precisely what information does the company collect?
  • Precisely what information does the company actually need to conduct business?


If the developer of the OnStar system had included a simple switch for turning the device off (disallowing any eavesdropping of any sort), the whole issue discussed in the ComputerWorld article would be moot. Unfortunately, no one thought to include such a switch, despite the fact that it would have been an obvious design addition. Of course, we don’t need to look specifically at OnStar as a bad example of privacy thwarted. Many applications today include a “call home” feature and won’t even work if you don’t have an Internet connection. In short, someone somewhere is spying on you constantly.

When you look for privacy-related design information for the developer online or in books, you find it mysteriously missing. The reader who called my book into question was right to do so. I hope that this small article has at least started you thinking about privacy and overcomes the omission in my book. Future posts will fill in some additional gaps, but I’d like to hear your perspective on the issue of privacy first. What questions do you have about privacy? How would you design an application that protects user privacy while meeting organizational needs for information? Let me know at John@JohnMuellerBooks.com.

 

Fun is Where You Find It! (Part 3)

Anyone can create work, but it takes some effort to create fun at times. It wasn’t very long after we started becoming self-sufficient that I discovered there would be a time each year where I’d need to work full time at helping Rebecca preserve the food from our orchard and garden. Of course, most people turn such events into work. After all, you’re working relatively long hours lifting heavy things in high temperatures and humidity. This is coupled with the repetitive motions needed to peel fruit and mixed with a bit of boredom waiting for things to happen—at least, that’s what happens if you’re most people. We’ve turned the event into Harvest Festivala party of sorts that we have every year. It has turned into my second favorite week of the year, right behind Christmas week, which will always remain my favorite.

So, what makes this week so special? Well, it starts out with some special mugs and music. We use festive mugs during Harvest Festival that we don’t really use any other time of the year, except when we’re performing other food preservation tasks. In short, these mugs are special. The music is similarly special. Yes, we do listen to some of it at other times, but the collection as a whole is reserved for Harvest Festival. Rebecca also sets the mood with scented candles that give the house a warm feeling.

HarvestFestival01

There are also times where we’re waiting for something to happen. We could probably get other work done, but we’re already working pretty hard, so some fun is in order. Rebecca and I play an interesting sort of Backgammon called Acey-Ducey that I learned while in the Navy. It’s easy to learn and a lot of fun to play. The games are short, so you can play a number of them quickly. Because the game is a mix of skill and chance, no one has the corner on winning. Of course, we have to drink some apple cider while we’re playing.

HarvestFestival02

The festival begins by picking the fruit from our trees. In fact, the entire first day is spent outside at the fruit trees. Some of the fruit is quite high, so I have to use a fruit picker to get it.

HarvestFestival03

After the fruits and vegetables are in the house (or at least enough to get started), we’ll start processing it. Just how we accomplish that task depends on what we’re making at the time. Rebecca started this year with pear-sauce (think applesauce made with pears). We also made pear chunks, applesauce, apple chips, apple rings, apple jam, and a host of other fruit-related confections for the larder.

HarvestFestival04

Our “kids” get involved with Harvest Festival too. The dogs are especially fond of apple spaghetti, which is the long streamer of peel that comes off of the apple. Here’s Shelby enjoying some apple spaghetti.

HarvestFestival05

The kids are known to do all sorts of cute things during Harvest Festival. Sometimes they’ll sit with us; other times they’ll make strange noises or grab attention in some other way. Smucker decided that he was going to be extra cute to get snack from us.

HarvestFestival06

Bubba has decided that he really likes Reese’s kennel, which has Reese confused, but us laughing. We found Bubba in the kennel quite a few times during Harvest Festival.

HarvestFestival07

Because the stove is being used to process food, we don’t have any place to cook—at least, not in the house. I try to barbecue each day during Harvest Festival so we have special food as well. Normally, we don’t get any beef, but I decided to make some really thick and juicy burgers for us one day. There is also plenty of nibbling going on with all of the available fruit. Although we keep some fruit for fresh eating, I think we eat the most fresh fruit during Harvest Festival, which makes the week quite special for that reason alone.

The result of all our work is jar upon jar of food for the larder. One of my favorites this year is the pear chunks. Rebecca makes regular, minted, and spiced. They’re all different colors to make them easy to find on the shelves.

HarvestFestival08

This year we processed 500 pounds of fruit, 480 pounds of tomatoes, 72 pounds of chicken, too many zucchinis to count, and a variety of other items all in one week. The result is that our larder is looking pretty nice (this is just half of the shelveswe also have two freezers and dry storage areas).

HarvestFestival09

There is still more to process in the garden. The beans are drying at this point. We’ll also be digging potatoes soon. I’m sure the zucchinis will produce a little more and the winter squash needs to be picked. However, Harvest Festival is our big push for the season and we have a lot of fun getting the food from our gardens and orchards to the larder. If you’re planning on a self-sufficient lifestyle, you’ll probably find a similar need for a “big push” week at some point during the season, depending on what you grow. Let me know if you have any question at John@JohnMuellerBooks.com.

 

Pondering Practical Play

People often ask me where I get ideas for my books or come up with solutions for business needs. The answer is simultaneously easy and difficult. One of the topics I don’t discuss often enough in books such as C# Design and Development is the need for play. If you don’t play, then you’re not spending your time wisely because play opens the mind to possibilities that you might not have considered. The essence of play is thinking about the impossible and making it happen. Many adults think that play is just for children, but play is for everyone.

I’m not talking about the sort of play that many people think about today. Exercising your thumb muscles during a video game isn’t the sort of play that promotes creative thought. Mindlessly watching the television doesn’t work either. The sort of play I’m talking about is where you look at something and decide to do the impossible with it. When a child plays, a block of wood can become nearly anything. A stick becomes a broomstick for riding, a sword for fighting, a flagpole with a banner attached (whether there is a banner to see or not), a magic wand, or literally thousands of other items. The stick is still a stick, but play makes it into something more.

Do you take time anymore to watch a spider spin a web? When was the last time you decided to imagine shapes in clouds? The colors that you see—are they really as dull as you think? These sorts of questions are answered during play. I played in another post on this blog. Read the Quick Sugar Free Cupcakes post again and you’ll see that I played with the batter until I created something that pleased both Rebecca and me. No, they weren’t the most exotic cupcakes ever made, but that isn’t the point of playdoing something new and interesting is what play is all about.

Practical play is goal-oriented. I’m currently writing a series of posts about a program named GrabAPicture that I created during play time. My only goal when I started creating that application (and many others on my system) was to see what I could do and what it would take to do it. I played with the code until I created an interesting application from it. How many developers take time to play today? If we had more developers playing, perhaps many of the problems that we’re facing today would already be fixed. So, I started GrabAPicture with a goalto change my desktop wallpaper in a certain way, but I didn’t place any restrictions on how I achieved my goal or how long I’d play until I was happy with it. The idea was to spend some time writing code for no other reason than the sheer joy of doing so.

In most cases, practical play is also more artistic, than scientific or concrete. Decorating eggs my not seem very practical, but I experimented with various color combinations as part of the process. The knowledge I gained has changed some of the things I do in my books. An idea experienced while decorating eggs has had a practical outcome in the way that I view color in my books. This is what play is all about.

Play is an essential part of the human experience. When you play, you free yourself from the bonds that normally keep you from thinking with your whole mind. A person who is playing is relaxed and free to think outside the normal boundaries that we set for ourselves. Some of the most influential thinkers throughout history have played. Read about Einstein and Edison as just two examples. You’ll find that they both played while others kept to the grindstone. How do you play? Let me know at John@JohnMuellerBooks.com.

 

Exploring the GrabAPicture Application (Part 2)

In the previous post, Exploring the GrabAPicture Application (Part 1), we discussed the basic parameters for the application—that it provides a means of changing the desktop wallpaper automatically, use online as well as local resources, and sports a command line interface (amongst other features). This post starts building the application.

You’ll start with the basic Windows Forms Application template. Rename the initial form as frmMain (this application will contain a number of forms) by right clicking the form’s entry in Solution Explorer and choosing Rename File from the context menu. This first form is the one that you’ll always see when you start the application from the command line. After you rename the initial form, add two more forms, frmAddEdit (used to add new entries and edit existing entries) and frmConfigure (used to display and manage the list of local and remote sources), by right clicking the project entry in Solution Explorer and choosing Add | New Item from the context menu. You saw the working version of these forms in the previous post.

 

I’m eliminating a few configuration features from the example for the sake of simplicity. For example, you should include tooltips with your version of the application to make it accessible. When the example is completely finished, you’ll be able to download the source code and see some of these additions for yourself.

Let’s begin with the design of frmMain.
Here’s how frmMain will appear.

GrabAPicture0201

This form lets the user type in the location of a piece of wallpaper and use it directly by typing something into Wallpaper Location, selecting a style in Style Selection, and clicking Set Value. The user can also click Random Sources to see a list of available wallpaper sources, which is actually the preferred method of interacting with the application because this technique lets the user save entries for future use. Close will close the form. The user can also use this form to choose whether to use local sources, remote sources, or both. The following table describes the control configuration for this form (add the controls to the form in the order shown to reduce the amount of configuration you must perform).

Control Property Value
Button1 (Name) btnOK
  DialogResult OK
  Location 208,8
  Modifiers Friend
  Size 104,23
  TabIndex 0
  Text Set &Value
Button2 (Name) btnConfigure
  Location 208,40
  Modifiers Friend
  Size 104,23
  TabIndex 1
  Text &Random Sources
Button3 (Name) btnCancel
  DialogResult Cancel
  Location 208,72
  Modifiers Friend
  Size 104,23
  TabIndex 2
  Text &Close
Label1 Location 8,8
  Modifiers Friend
  Size 144,23
  TabIndex 3
  Text &Wallpaper Location:
TextBox1 (Name) txtWallpaperURI
  Location 8,32
  Modifiers Friend
  Size 176,20
  TabIndex 4
GroupBox1 Location 8,64
  Modifiers Friend
  Size 192,100
  TabIndex 5
  Text Style Selection
RadioButton1 (Name) rbStretched
  Location 16,24
  Modifiers Friend
  Size 104,24
  TabIndex 6
  Text &Stretched
RadioButton2 (Name) rbCentered
  Location 16,48
  Modifiers Friend
  Size 104,24
  TabIndex 7
  Text &Centered
RadioButton3 (Name) rbTiled
  Location 16,72
  Modifiers Friend
  Size 104,24
  TabIndex 8
  Text &Centered
CheckBox1 (Name) cbLocal
  Location 8,176
  Modifiers Friend
  Size 184,24
  TabIndex 9
  Text Use Random &Local Sources
CheckBox2 (Name) cbRemote
  Location 8,208
  Modifiers Friend
  Size 184,24
  TabIndex 10
  Text &Use Random Remote Sources

Next time we’ll look at two other forms. The first helps the user manage local and remote sources. The second will provide the means for adding or editing individual entries. Let me know if you have any questions at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the GrabAPicture Application (Part 3).

 

Creating a Global Toggle Button

I’ve worked through a number of odd issues with the Ribbon and VBA in this blog and in two of my books VBA for Dummies and RibbonX for Dummies. For example, the Creating a Custom Styles Group post shows how to make a gallery look correct when you move it to a custom tab. Likewise, the A Quick Method for Adding Custom Ribbon Elements post demonstrates a new technique for customizing the Ribbon using built-in Office 2010 features. Unfortunately, those posts won’t show how to add some specialty controls to your custom Ribbon, such as a toggle button, that also automatically loads when Excel opens. In fact, most people assume that any custom Ribbon element must be added to the individual worksheet or as part of an Excel add-in. This post will dispel that notion.

Before you begin this article, make sure you’ve read the Creating Global Macros in Excel 2007 and 2010 post. You need to understand things such as the location of the PERSONAL.XLSB file on your system and its purpose. Of course, the main purpose is to provide a means of creating global applications that load immediately when Excel loads.

If you try to add a toggle button directly to the PERSONAL.XLSB file, you’re going to quickly find that the process doesn’t work. I tried for hours to get the toggle button to even appear. Regular buttons work fine. You can also easily add galleries using techniques I’ve discussed before, but toggle buttons proved elusive at best.

The trick is to think outside the box. You can create an individual file that contains a toggle button without any problem. Yes, it does require that you create a customUI entry in the application either directly (by changing the file extension of the file to .ZIP and adding the correct elements) or by using an editor, such as the CustomUI Editor. This post won’t cover the basics of creating a custom tab. If you don’t have a copy of RibbonX for Dummies or VBA for Dummies, you can find this information on a number of sites, including MSDN.

Begin by creating a standard Excel workbook and saving it an Excel Macro-Enabled Workbook (.XLSM file). You’ll need to add a custom tab, group, and toggle button to your workbook. Here’s the code I’ve used for this example. It’s nothing elaborate. In fact, I purposely made it simple to ensure that the post would focus on technique.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI onLoad="RibbonLoaded"
  <ribbon>
    <tabs>
    <tab id="myTab" label="My Tab">
      <group id="myGroup" label="My Group">
             <toggleButton id="SayHello"
                           label="Toggle SayHello"
                           onAction="SayHello_Click"
                           getPressed="SayHello_Pressed"
                           size="large"
                           imageMso="HappyFace"/>
      </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

This toggle button has two events it must handle: onAction and getPressed. In addition, you must load the Ribbon before you can make anything work. To make the button functional, I needed to add the following macros and global variables to the workbook.

' Define a global variable to hold the Ribbon reference.
Dim Rib As IRibbonUI
 
' Determines the behavior button state.
Dim lBehavior As Boolean
 
' Callback for customUI.onLoad
Sub RibbonLoaded(ribbon As IRibbonUI)
 
    ' Save the ribbon reference.
    Set Rib = ribbon
     
    ' Initialize the behavior state.
    lBehavior = False
     
    ' Show a status message.
    MsgBox "Ribbon is Loaded."
End Sub
 
' Callback for SayHello onAction
Sub SayHello_Click(control As IRibbonControl, pressed As Boolean)
 
    ' Change the behavior state.
    lBehavior = pressed
     
    ' Update the control.
    Rib.InvalidateControl (control.ID)
     
    ' Display the status.
    If pressed Then
        MsgBox "The toggle button is pressed."
    Else
        MsgBox "The toggle button isn't pressed."
    End If
End Sub
 
' Callback for SayHello getPressed
Sub SayHello_Pressed(control As IRibbonControl, ByRef returnedVal)
 
    ' Return the current behavior state.
    returnedVal = lBehavior
End Sub

Don’t forget to make sure you define the relationships if you’re editing the file by hand. OK, at this point you have a toggle button that’s functional. If you save this file, close it, and then reopen it, you’ll find that you can click the button and it’ll tell you its state—either pressed or not pressed. That’s not really the big deal here.

Now, save your file as an Excel Binary Workbook (.XLSB file). Rename this file PERSONAL.XLSB and copy it into your XLSTART folder (such as, C:\Users\John\AppData\Roaming\Microsoft\Excel\XLSTART on my system). You’ll suddenly find that you have a global toggle button. It loads every time Excel loads and the macros work just as you’d expect. Please let me know if you have any questions about this technique at John@JohnMuellerBooks.com.

Consumerization of IT as it Relates to Developers

In my book, C# Design and Development, I discuss the need to consider the application environment in a number of places. For example, on page 106 you’ll find a discussion of the corporate environment on the requirements for application speed. A discussion on page 431 describes the need to achieve application goals while treading softly on the user’s environmental settings. Application environment can include a lot of different considerations. That’s the reason the ComputerWorld article entitled, “‘Consumerization of IT’ taking its toll on IT managers” struck a cord with me today. IT is now faced with a situation where users rely on personal devices more often than corporate-supplied devices, which is wreaking havoc in many ways.

The article will enlighten you about the woes that IT faces. What the article doesn’t describe are the woes that the developer faces. When an application developer creates a new application for the corporate environment or provides changes to an existing application, the testing process must consider the devices that the application will run on. When the developer works with a known set of corporate-supplied devices, the testing process is predictable. However, when the developer must also consider personal devices, the testing process is more like the environment for shrink-wrapped software, which means that the developer must now consider an open environment in which the user could rely on any device. In fact, developers must consider the following application design, development, and testing issues as a minimum due to consumerization.


  • Security: Early corporate applications didn’t come with much security at all. As government regulations, data breaches, and other issues have come to light, developers have added security to application, but not at the level of shrink-wrapped software and certainly not enough to ensure protection of corporate data.

  • Reliability: Every device that accesses an application has different characteristics. These characteristics determine how the device interacts with the application. Adding devices increases the number of potential interaction types and reduces overall application reliability due to issues with non-compliant devices. Obviously, testing can no longer have even a hope of finding every application interaction issue, so developer will need to create a robust application error handling mechanism with the organization.

  • Presentation: As device types increase, so do the presentation environments that the application must service. It isn’t just the fact that these devices will have different sized screens, but also the need to address audio and input characteristics of a wide range of devices. A developer must now consider how best to define an application interface so it works with the broadest range of devices possible.

  • Multiplatform Considerations: A development staff may begin designing an application to work on a particular platform, such as Windows, only to find that users also want the application to work on Android or the iOS. Even when the user sticks with desktop or tablet devices, the application may need to support Linux or OS X. In short, the development staff needs to consider multiple platforms when creating an application today. Unfortunately, Web-based applications aren’t always the best choice—leaving the development staff with some tough decisions to make.


There are other considerations to make, but you get the idea. Today’s development environment has become extremely complex due to consumerization. Unless your organization has firm policies about personal device usage in place and actually acts on those policies, you need to consider the idea that the user could access your application using just about any device on the market today. You have a number of ways to deal with this situation, including the following suggestions:

  • Create a list of tested configurations so that users know which devices are most likely to work with the application.
  • Make users part of the initial design process so that you hear about needed device support as early as possible.
  • Track new device releases because many users will get the latest gadget and expect it to work with your application.
  • Define a specific procedure for adding new devices to the application support list so that you don’t have to deal with user requests in a confused manner.
  • Keep an open mind because users will work with personal devices whether you support them or not.


This whole issue of consumerization could easily consume a chapter or more in a book. What have your experiences been with consumerization? Is the new application development environment becoming impossible to manage? Let me know your thoughts at John@JohnMuellerBooks.com.

Review of HTML5 Step by Step

Microsoft has thrown developers yet another curve—Windows 8 will rely on HTML5 and JavaScript for a programming interface. The revelation has many developers horrified. For me, it means updating my HTML and JavaScript skills, which was one motivation for reading the book reviewed in today’s post. HTML5 Step by Step, written by Faithe Wempen, provides a quick method of getting up to speed on HTML5.

This book is designed to aid anyone who wants to know how to work with HTML5, which means that it starts out extremely simple. The book avoids the ever popular Hello World example, but the example it does provide is small and easily understood. The chapters don’t remain simple, however, so even if you have some experience with HTML, you can use this book to update your skills. You’ll likely want to start around Chapter 3 if you are experienced and skim through the material until you come to something unfamiliar, which could happen relatively fast given the changes in HTML5.

HTML5 Step by Step is light on theory and reference information, but heavy with hands on experiences. It relies on using Notepad as an editor, which may seem like an odd choice, until you read the “Why Learn HTML in Notepad?” section of the Introduction. The author’s reasoning is akin to the same reasoning I would use, which is to make sure that the reader types everything and understands why a particular element is required. If you really want to get the most out of this book, you have to do the exercises in Notepad as the author suggests. Otherwise, I guarantee you’ll miss out on something important. Faithe has made a great choice of teaching aids in this case.

Chapter 1 is most definitely designed for the rank novice. It even shows how to set up the examples directory as a favorite in Notepad. However, unlike many books, the rank novice should read the book’s Introduction because Faithe does provide some needed information there, such as the “Understanding HTML Tags” section.

Chapter 2 gets the reader started with some structural elements. Faithe covers everything that the reader is likely to need for a typical starter Web page. I wish that the chapter had covered <meta> tags in a little more detail, or at least provided a table listing them, but this book does have an emphasis on hands on exercises, so the omission isn’t a glaring one. As an alternative to including the information, an update could provide a URL that lists the tags so the reader knows where to go for additional information.

By Chapter 3, the reader is formatting text and starting to make the sample site look pretty. I really thought Faithe did a nice job of moving the reader along at a fast, but manageable pace. She shows the reader how to make effective use of tag combinations, such as the <kbd> (keyboard) and <b> (bold) tags.

There is the smallest amount of reference information in some chapters. For example, Chapter 4 contains a table on page 50 showing the list attributes. These references are very small and quite helpful, but the reader should understand that the emphasis is on doing something and that the reference material may not be complete. For example, the special symbols table on page 56 is missing the em dash, which is something most people use.

The book progresses at a reasonable pace. Never did I find myself rushed. The examples all seem to work fine and I didn’t find missing steps in the procedures. The author uses an adequate number of graphics so that the reader doesn’t get lost. I liked the fact that every exercise ends with a cleanup section and a list of the major points that the reader should have gotten from the exercise.

Readers who are only interested in new tags will need to wait until Chapter 9 to see one. The <figure> tag makes an appearance on page 141. However, even some professionals didn’t use all of the HTML4 tags and it really does pay to start at Chapter 3 and look for something you don’t recognize. It may surprise you to find that an earlier chapter contains a somewhat new (but not new to HTML5 tag) that you’ve passed by.

There are a few nits to pick with this book. The first is that the author places the accessibility information in an appendix where almost no one is going to read it. The information should have appeared as part of the rest of the book as appropriate. In addition, the author misses the big point that most people today have some sort of special need addressed by accessibility aids. The number of people who are colorblind alone is 8 percent of the male population and 0.5 percent of the female population. This book is unlikely to help you create a truly accessible sitenot that this is the reason you’re buying the book.

The second is that Appendix C doesn’t really help very much with the additions and subtractions for HTML5. For example, Appendix C doesn’t tell you about the new <aside> tag. If you want a quick list of the new tags, check out the www.w3schools.com HTML5 New Elements page. (I checked the missing <aside> tag against a number of other sites, such as About.com.) The point is that Appendix C won’t give you the complete picture. Again, this isn’t one of the selling points of the book, but the list should have been complete.

The third is that there isn’t really enough information about why something is done or why it changedsimply that it must be done or that it did change. The reader probably doesn’t want a full blown history of the change, but the why of something can make understanding and, more importantly, remembering a concept easier. Still, this particular nit is minor since the purpose of the book is to get you started with HTML5 quickly and not to explore it at a theoretical level.

Overall, HTML5 Step by Step is a great book for the novice who wants to learn how to create Web pages. It’s also an acceptable book for someone who’s experienced with HTML coding, but wants to get up-to-date on the HTML5 changes quickly. This book is definitely designed for someone who wants to do something, rather than simply read about it. If you don’t perform the exercises, you won’t get much out of the book.

 

Okra Pollination Problems

Every gardener faces the eventual problem that can’t be easily solved by talking with friends or looking online. This year presented one of those problems for us. We have big okra plants that aren’t producing any pods. Yes, there are a lot of flowers, but they aren’t producing anything. Instead, the flowers are opening, shriveling back up, and then dying as shown here.

Okra

You can see two flowers in this picture—both of which have dried up without producing fruit. All five of our okra plants are precisely in the same condition. They’re all nice big plants, but nothing to show for an entire summer’s worth of growth except some exceptionally beautiful leaves and dried flowers.

According to any number of sites, okra is self-pollinating in many cases. However, many of these sites also indicate that there hasn’t been any study done of the pollinators for okra and their effect on the plant. When I first noticed this problem, I spent time on a sunny day observing the plants carefully. A number of pollinators visited the plants, so it seemed at first that the issue isn’t one of pollinators.

However, I also noticed something else. On every other year, the okras in our garden are infested with ants. This year, there is not an ant to be found anywhere near our okra. A number of sites seem to indicate that the ants have no purpose for okra, but everyone complains about them. Now I’m starting to wonder whether the ants are pollinators or somehow help the plant in other ways. The okra certainly seems to put out a nectar that attracts ants like crazy.

The only other change in that particular part of the garden this year is that the patch has tomatoes in it. The okra is growing in row 4 of that patch and the tomatoes are growing in rows 1, 2, and part of 3. Last year, the okra was in row 1 of the same patch. Checking for relations between okra, tomatoes, and ants online proved fruitless. In short, there is no quick or easy answer for this particular problem except to say that it exists.

Our summer has been hot enough for the okra to grow quite large, so I’m sure it’s not a problem with heat. The okra has also been mulched and watered, so moisture isn’t a problem. Because the okra has been moved to a new row and that patch also received a nice layer of new mulch this past spring, it can’t be nutrients. I’ve checked the flowers and each one is producing the same amount of nectar as normal. I keep coming back to the lack of ants or some deleterious effect of putting tomatoes and okra in close proximity. If anyone else has a thought on this issue, please contact me at John@JohnMuellerBooks.com.