Home
Banner
Writing a Project Wizard Print E-mail
At first you should try, to get the demo wizard running, just to get an idea of how things are working.

To make it easier for you, we have included the content of the demo wizard directory together with the compiled wizard DLL as a ZIP-file.

First step should be to get the wizard running. Therefore, you should simply copy the DLL from the attached archive into a subdirectory of one of your project template directories (like every other project template).

Like every COM-server-DLL you will have to register this DLL with the system. There for you should open a command line, go to the directory the DLL has been placed in and call "regsvr32" with the DLLs name as command line parameter. A dialog box should appear, that tells you, that the DLL has been registered successfully.

Now you can startup TeXnicCenter and choose the 'File|Create new project...' menu item. In the template list, that represents the template directory you have placed the DLL in, you will now find the wizard (it has some special icon and the name "Demo"). Choose it as template, type a dummy project name and click the 'Create' (or something like this) button of the template dialog.

A dialog will appear, which tells you the name of the project, you have typed in and provides you the possibility to press OK and create a new empty project or press Cancel and so cancel the creation of the project. This dialog is not from TXC -- it has been created by our demo wizard!!!

Now you can take a look into the VisualBasic source file, even without having VisualBasic installed. The interface we have implemented in the demo wizard is the IProjectWizard-interface. There are some properties, which are relevant for how to display the wizard in the template list, but the most important is the "DoModal()"-method.

This one is called, when the users has selected this wizard as template and clicked the create button in the TXC template dialog. What you get passed as parameters is a pointer to an IProject interface, which contains some information about the project to create, like i.e. the Path and the title of the new project and a string, that should be used as line feed in the created text files. The value of this string depends on the settings the user has made for the file type (UNIX, DOS, MAC).

Now its up to you, to create dialogs and wizards, to provide your options to the user and create all the necessary files. Leave the method with "1" if the project creation was successfull or with "0" if there was an error or the user cancelled your wizard. In the second case, your wizard is responsible for removing all files that have already been created for the project.


The class name should be the logical name of your wizard. The base name of the resulting DLL will have to have exactly the same name. For example, if your wizard should be listed as 'MyWizard' in the template dialog of TXC, the DLL must be called 'MyWizard.dll' and the class name that implements the wizard (the IProjectWizard interface) has to be called 'MyWizard.ProjectWizard' -- otherwise TXC won't be able to create the COM-object (see below for details).

Here are the details about how TXC loads the wizards: When a template dialog is opened up, TXC searches for .tex and .DLL-files in all subdirectories of all specified template directories. If it finds a .DLL-file, it takes the title of that file (the file path without directory and without extension) adds the string ".ProjectWizard" and calls the Win32-API function CoCreateInstance() for the resulting string which is interpreted as a COM-Prog-Id. So when creating new wizards you have to give the the Prog-Id "MyWizard.ProjectWizard" and the DLL has to be called "MyWizard.dll". If you want to learn more about how the wizards are used, take a look into the CWizardBasedProjectTemplateItem-class in the file ProjectNewDialog.cpp of the TeXnicCenter project.


 

Featured Book

Advertisement

Related Sites

powered by
SourceForge.net Logo

official support by
LaTeX Community