Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CodeProject Quoter

0.00/5 (No votes)
23 Jun 2003 3  
Simple tool for storing and retrieving the quotes and using them in the signatures.

CP Quoter - Main Form with HTML View - jpgCP Quoter - Main Form with HTML Source - jpg

Introduction

Notice : This is not an article, but a simple tool for serious CPians who use the quotes in their signatures. To be frank I doubt you will learn anything new here.

Any frequent visitor to Lounge or Message boards would have observed the amazing quotes used by fellow CPians in their signatures. The fun part is most of these quotes are from the messages posted by none other than fellow CPians! And some folks often change their signatures with the new quotes frequently.

I tried to do the same. But it's kinda of tough with the current CP's signature option. Following are the 3 options I tried. Two of the options are from CP and the remaining one from DesktopBob application.

Option 1: Default signature for all the messages (My Profile -> My Settings)

'CPQ - Signature option via Settings - jpg

Disadvantage: In this option the formatting toolbar is not available.

Option 2: Changing the default signature on any new message

CP - Signature option - jpg

Disadvantage: You can't preview instantly. For that you have to use the 'Preview' button. Even after your modifications and when you ready to post sometimes you get the CP's easter egg "The operation failed unexpectedly. Please try again."

Option 3: Changing the default signature on any new message via DesktopBob

Disadvantage: There is no GUI to add the quotes to signature XML file. So you have to open the XML file and add each quote one by one.

Option 4: :-)


Just Kidding. Enough bragging.

So then comes CPQ, easy way to store the quotes (XML format) and retrieve them and use these quotes with in the signatures so that it can used in CP, DesktopBob and Outlook.

Key features

  • All the quotes are stored in the XML file.
  • Multiple collections of quotes. (Ex: CPiansQuotes.html, DubyaQuotes.html)
  • HTML support for the quotes (like Bold, Underline, URL support)
  • Add and Remove quotes from a collection.
  • Random quote from a collection.
  • HTML Source option for the quote.
  • Copy the quotes to Clipboard in Text and HTML format.
  • Copy the quotes to Outlook signatures location in Text and HTML format.

Original Idea

One of my ex-colleague James Huckaby developed a similar tool (with no HTML and XML support) in VC++ but with more bells and whistles.

Technical Details

Class Library

It's a simple application. I have used the CollectionBase class for the QuotesCollection and it contains the Quotes which is derived Object. I wrapped these two classes into a class library.
  • public class QuotesCollection : CollectionBase
  • public class Quotes : Object
The main reason for using CollectionBase as base class because of it's it supports these interfaces IList, ICollection and IEnumerable.

GUI

For the GUI part I have used the HTMLEditor which is a wrapper for MSHTML, the rendering portion of Internet Explorer (and IE's largest single component). It is written by Tim Anderson in C#.

Note: The "HTML Editor" requires Microsoft.Mshtml.dll Primary Interop Assembly. VS.Net installs this in Program Files\Microsoft.Net\Primary Interop Assemblies.

I have used few "http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/ifaces/document2/execcommand.asp">command identifiers to pass them as parameters to "http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/ifaces/document2/execcommand.asp">IHTMLDocument2::execCommand which executes the command on the current HTML document.

I am not a good narrator like Marc Clifton or Mike Dunn, as my grammar sucks. So why don't you guys go through the code and see what I did.

How to use this tool

The GUI is very simple. Just run the app, add all the quotes via Edit -> Add new quote.. menu item(shortcut Ctrl + Q). The new added quote will be displayed under "Quote" tab, which is an actually a HTML Editor. So if you want HTMLize the quote then use the available options (font name, size, color...etc..) from the toolbar.

To see the "HTML Source", click on HTML tab. If you want to use the HTMLized quote, just copy the from text within BODY HTML tags from textbox control under the HTML Tab. There are more options under Edit->Copy menu.

CPQ- Copy options jpeg

Example

Actual Quote:(George W Bush)

"I was raised in the West. The west of Texas. It's pretty close to California. In more ways than Washington, D.C., is close to California."
--Los Angeles Times, April 8, 2000

HTML Source

<P align=center>
"<FONT face=Tahoma color=blue size=4><STRONG>I was raised in the 
West.</STRONG></FONT> 
<STRONG>The west of Texas</STRONG>. <FONT face="Fine Hand" 
color=black><FONT size=4><STRONG>
It's </STRONG><FONT face=Verdana 
color=green><U>pretty close to California.</U></FONT></FONT></FONT>
<FONT face=Verdana 
color=red size=4><STRONG>In more ways than Washington, D.C., 
is close to California.</STRONG></FONT>" --<EM>
<FONT face=Harrington color=fuchsia 
size=4><STRONG>
<A href="http://www.latimes.com">%20 los/ Angeles Times</A>, 
April 8, 2000</STRONG></FONT></EM> </P>

HTMLized Quote

I was raised in the West.The west of Texas.It's pretty close to California.In more ways than Washington, D.C., is close to California."--Los Angeles Times, April 8, 2000

Desktop Bob users

I have the used the same XML format DesktopBob uses for it's signature rotation tool.

So add all favorite quotes via CPQ and feed the whole XML file to DesktopBob.

CPQ - XML Format style

Outlook users (version 2000)

With the CPQ, you can direct your quotes to Outlook signatures location.
Choose the quote you want for Outlook and copy it to Outlook via Copy -> Quote to Outlook (HTML) or Quote to Outlook (Text) menu options.

  1. From Outlook go to the Tools menu, click Options, and then click the Mail Format tab.
  2. In the Send in this message format box, click the message format (Plain Text or HTML) you want to use the signature with.
  3. Choose 'CPQSig' from the 'Use this Signature by default' combo box under the Signature group.

CPQ - Outlook options jpg

Quirks


  1. Disabled the context menu in HTML Control.
  2. When the app is closed the tray icon won't disappear immediately from the Taskbar Notification area.
  3. HTML copy options require the focus in the HTML tab.
  4. When you select the font size in the Font Dialog it needs to be in sync with the HTML style. (Ex: Use the size less than 3 or 4)

 Thanks to

To-do List


  • Writing the random quote to Outlook signatures location on a timer.
  • MDI Support
  • Spell Check support.
  • Option to turn off to the HTML. It's for those who don't like HTML formatting.
  • Fix the bugs found by you.

Last but not the least


This is my first project at CP, that too my first managed project. Don't be scared from my MFC habit of coding. If you find any bugs(which you will), or if you have some enhancement suggestions, just post a message on this page. I hope you enjoy CPQ!

Updates History

06/24/2003: 1.1 Release

  • Added new menu options for the tray icon.
  • Random quote which is equal to Random Quote + Copy Quote to Clipboard (Text)
  • Add new quote
  • Open collection

    CPQ - Tray Icon option jpg

  • Added option of opening a quote collection from web in the File -> Open menu.

CPQ - Open options jpg 

  • Open Collection from Web dialog

CPQ - Open options jpg 

Tip: Just for fun, enter CP's RSS feed here ;)

  • Added code for checking for pre-requisites
    • Check for .NET Framework
    • Check for Visual Studio.NET
  • Added support for copying the whole XML file to DesktopBob and AutoSig application locations.
  • Used a new form for Config options and stored them in the config (XML) file.

06/03/2003: Second Release

Fixed the following bugs:

  1. The "Random" function doesn't updating the quotes count properly.
  2. Copy sub menu items ordered properly.
  3. Adding new quote shows up properly in the HTML Editor control.

Found new bug in the new quote dialog, it's messing up the newly added quote. I will fix it later, so for time being I commented that code.

06/03/2003: First Release

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here