The WinForms Notepad Project: Application Name Ideas (Premium)

As our Notepad clone becomes more feature complete, we’re going to need a final name for the application, since NotepadWF is obviously not a great name. I still haven’t come up with a name that I really like---see below---but we should prepare for the inevitable epiphany moment by replacing all of the explicit references we’ve made to “NotepadWF” in the code and instead access the application’s name programmatically. That way, we can easily change to a new name at any time. (And, yes, I should have coded it this way from the beginning.)

You’ll find several references.

First, open Form1.vb and double-click on the main form’s title bar in the designer to display the Form1_Load event handler in Form1.vb. Then, add the following line right at the top of the event handler, above the code that’s already in there:
Me.Text = Application.ProductName
Next, search for all of the instances of “NotepadWF” (no quotes) in the code that are not part of event handler names. You’ll find several. In NewToolStripMenuItem_Click alone, there are two lines of code that use this name.

The first currently reads as:
Dim SavePrompt As DialogResult = MessageBox.Show("Do you want to save changes?", "NotepadWF", MessageBoxButtons.YesNoCancel)
Change that to:
Dim SavePrompt As DialogResult = MessageBox.Show("Do you want to save changes?", Application.ProductName, MessageBoxButtons.YesNoCancel)
The second currently reads as:
Me.Text = "Untitled - NotepadWF"
Change that to:
Me.Text = "Untitled - " + Application.ProductName
Next, find the OpenToolStripMenuItem_Click event handler. This contains a line of code that reads:
Me.Text = OpenFileDialog1.SafeFileName + "- NotepadWF"
Change that to:
Me.Text = OpenFileDialog1.SafeFileName + "- " + Application.ProductName
Now, find the Form1_Closing event handler. It contains a line of code that now reads as:
Dim SavePrompt As DialogResult = MessageBox.Show("Do you want to save changes?", "NotepadWF", MessageBoxButtons.YesNoCancel)
Change this to:
Dim SavePrompt As DialogResult = MessageBox.Show("Do you want to save changes?", Application.ProductName, MessageBoxButtons.YesNoCancel)
Finally, find SaveFileDialog1_FileOk. Here, you will find a line of code that reads:
Me.Text = Path.GetFileNameWithoutExtension(DocumentName) + "- NotepadWF"
Change this to:
Me.Text = Path.GetFileNameWithoutExtension(DocumentName) + "- " + Application.ProductName
OK, that should do it.

Of course, testing this is difficult because you should notice no changes to the display of the application name in the main form or elsewhere. But you can test this by temporarily changing the application name in Application Settings. To do so, right-click the project’s name in Solution Explorer, choose Properties, and then navigate to the Application tab. Click the Assembly Information button and then change the Product field in the resulting window to something different, like “Yoghurt” (no quotes). Click OK, and...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC