Talk:ITrack/Creating an Extension
From ISoft Wiki
Revision as of 16:30, 18 November 2009 by Jmckinstry (talk | contribs) (Developer's in-depth description of how to create a new extension.)
Follow these steps to create a new extension in ITrack (using Master):
- File->New, Projects Tab, MFC AppWizard (dll), give it a sensible project name, confirm that the project goes into a space you expect it to, then press OK
- Choose Regular DLL using shared MFC DLL, then press Finish, then OK
Now that your project exists, clean up the space by doing the following:
- Delete <project name>.h
- In <project name>.cpp, delete everthing below the include/define section
- Open up an existing extension .cpp, such as EEHome.cpp, copy everything below the include/define section, and spam it into <project name>.cpp
- Mass-replace the name of the old DLL with the name of the new DLL (EEHome with EE<extension name>, for example)
- Add '#define SCREEN_NAME "<extension name>" somewhere where it will get included (probably want to create a standard header for this)
- If your project will hide its entry (users can't choose to open it), change itView.bIsNavigator to FALSE
- Change the LoadIcon call to use IDR_<extension name>
- In the section where the CMultiDocTemplate is created, change the first parameter to IDR_<extension name>, the second parameter to ITEmptyDocument, the third parameter to ITChildFrame, and the fourth parameter to <extension name>View
- If you choose to use an underlying document, change ITEmptyDocument to the class name of your document class, and have that extend ITDocument
- Add the following includes:
- include "resource.h"
- include "<extension name>View.h"
- include "<trunk>/Shared/Tools/ITExtension.h"
- include "<trunk>/Shared/Tools/ITChildFrame.h"
- include "<trunk>/Shared/Tools/ITExtension.h"
Next, we have to configure the project space:
- Open project settings, go to the C/C++ tab
- In Preprocessor Definitions, change _USRDLL to _AFXEXT
- Change the Category to C++ Language, and then set Enable Run-Time Type Information (RTTI) to be checked
- Go to the Link tab
- Set your Output File Name to the output directory of the project you wish it to be in
- Use relative paths (../../../bin/Debug) instead of absolute paths (C:\lolz\bin\Debug)
- Set your Object/Library Modules to: <libraries>/lib/libITSQLFramework_d.lib <libraries>/lib/libITSQL_d.lib
Once that's done, we need to tack on the resources for the new extension:
- Click on your Resources View
- Insert a Dialog->IDD_FORMVIEW
- Change the view's resource ID to IDR_<extension name>
- Press Ctrl+W to get to the class wizard. It will ask you to create or choose a class for your view. Create a new class, call it <extension name>View, and make sure its base class is CFormView
- Insert a String Table
- Create a new string, set the ID to IDR_<extension name>, then give it the text that you want your extension window to show
- Insert an icon
- Press Enter until you can change the ID, then change it to IDR_<extension name> and make the icon whatever you want
Almost there! Go back to your File View and:
- Open Resource.h, change the values set at 1000 to your extension's resource range (which can be found in a project's root directory, with the name 'ResourceRangeReservations.txt')
- Change the value for IDR_<extension name> to 1 + your resource reservation value
- Add two new source folders, tools.cpp and tools.h
- Add ITChildFrame.(cpp|h) and ITExtension.(cpp|h)
Compile, add the dll to ITrack, and watch it run!
- todo: Must add information on how to maximize the screen, and include message handlers from Master