AIMCC C# Plugin Tutorial


Lesson 4 : Adding a Preferences Page

You may want to allow users to adjust settings for your plugin. AIMCC applications will display a "Settings" button for plugins when displaying the list of installed plugins, which plugins can use to pop up a preferences dialog box.  To add a preference form to your plugin, add a reference to "System.Windows.Forms" in the project.  Then add

using System.Windows.Forms;

to your plugin file.

To receive notification of the Settings button being clicked, we must implement the IAccCommandTarget interface.  Implementing IAccCommandTarget is done the same way that we implemented IAccPlugin in lesson 2. We add the code below to make our class inherit from IAccCommandTarget:

. . .

    public class Class1 : IAccPlugin, IAccCommandTarget

. . .

We will now have two new methods in our plugin class - Exec and QueryStatus. QueryStatus is called when AIMCC asks the plugin about the status of a command; you can return a true/false value to indicate whether the command should be enabled or disabled. Exec is called when AIMCC invokes a command on the plugin.

For our preference page, we will focus on the Exec implementation. When the Settings button is clicked, AIMCC will invoke the Exec method with the command AccCommandId_Preferences. We will look for that and display a dialog box when this occurs.

. . .

    public void Exec(int command, object users)
    {
        if (command == (int)AccCommandId.AccCommandId_Preferences)
        {
            Form MyForm = new Form();
            MyForm.Text = "My Plugin Settings";
            MyForm.Show();
        }
    }


   
public bool QueryStatus(int command, object users)
    {
        if (command == (int)AccCommandId.AccCommandId_Preferences)
            return true;
        else
            return false;
    }


. . .

If you now rebuild your plugin, your dialog box will be displayed when your plugin's settings button is clicked.

Next Lesson | Back to Table of Contents


Questions? Visit http://developer.aim.com/
Last updated: 03/17/2007