Making an
Extension with Cragmyre's SDK Template
Download
Cragmyre's SDK Template
Basic Set-up
- Define various values in the Extobj.rc file and edit
icons. List of Values to
Define
- Set your flags and preferences.
- They're located at the bottom of Main.h:
// Default flags
// -------------
#define OEFLAGS 0
#define OEPREFS 0
- Just change the 0 to whichever flags or preferences you
want (flag | flag | flag)
- List of Flags and
Preferences
- Determine what data your object will need to store at
both edit-time and at run-time. Define the run-time data
in the RUNDATA (tagRDATA) structure and define the edit-time
data in the EDITDATA (tagEDATA) structure. Both
structures can be found in the Main.h file. Note: If you
need to update the EDITDATA structure of your object in a
later version, you'll have to use the UpdateEditStructure
routine in the Edittime.cpp file to update the structure.
IMPORTANT: the Header objects (headerObject
and extHeader) need to be the FIRST entries in the
RUNDATA and EDITDATA structures respectively.
- Create your set-up dialogue.
- If you do not need a set-up dialogue, remove it from
Extobj.rc and remove the call of the DialOpen routine in
the CreateObject routine in the Edittime.cpp file. Simply
have the CreateObject routine return 0. You also need to
remove the call of the DialOpen routine in the
SelectPopup routine in the Edittime.cpp file.
- If you are going to use a set-up dialogue, create it in
the Extobj.rc file. Then go to the setupProc routine in
the Edittime.cpp file. Under the WM_INITDIALOG case, set
all of the controls to the proper value based on the data
in the EDITDATA structure. Under the IDOK case, get the
data from the controls and set the data in the EDIDATA
structure appropriately.
- Initialize the edit-time data for the EDITDATA structure
in the CreateObject routine in the Edittime.cpp file.
- Set-up any of the other routines in the Edittime.cpp file
that your object will use. List
of Edit-time Routines
- Initialize the run-time data for the RUNDATA structure in
the CreateRunObject routine in the Runtime.cpp file. This
routine is called when MMF creates one of your objects at
run-time.
- Clean up any memory allocated by your object in the
DestroyRunObject routine in the Runtime.cpp. This routine
is called when MMF destroys one of your objects at run-time.
- Set-up any of the other routines in the Runtime.cpp file
that your object will use. List
of Run-time Routines
Create Conditions
- Add entries to the conditionsInfos array at the top of
the Main.cpp file. Each entry should use the following
format:
Menu ID, String ID, Condition Code, Flags, Number of
Parameters, Parameter Types, Parameter String IDs,
List of Condition Flags
and Parameter Types
- Create routines for each of your conditions in Main.cpp.
The function header for condition routines is long
WINAPI DLLExport Name(LPRDATA rdPtr, long param1, long
param2). If your condition has less than 3
parameters, you can use param1 and param2
as those parameters. If you have more than 2 parameters,
you must get all of your parameters using CNC_GetIntParameter(rdPtr),
CNC_GetFloatParameter(rdPtr), or CNC_GetParameter(rdPtr),
which will return each parameter on subsequent calls.
Getting Parameters
- Add pointers to the condition routines you've created to
the ConditionJumps array at the bottom of Main.cpp. The
order of condition routines in this array must be the
same as the order of conditions in the conditionsInfos
array.
- Define your condition codes in the Main.h file. The order
of these codes, which must be defined sequentially (0,1,2,3,etc.),
must be the same as the order of the conditions in the
conditionsInfos array. CND_LAST must be the last
condition code defined.
- Define the Menu IDs, String IDs, and Parameter String IDs
(the ones you used in the conditionsInfos array) in the
Resource.h file.
- Add your conditions to the MN_CONDITIONS menu in the
Extobj.rc file, using the Menu IDs you used in the
conditionsInfos array.
- Define the condition and condition parameter strings you
used in the conditionsInfos array. The condition
parameter strings are displayed in the heading of the
expression evaluator when the user is inputting the value
for that parameter. The condition string is displayed in
MMF's event and event list editors. In that string, you
can use %o to display your object's icon and %# to
display the given parameter (%0 is the first parameter, %1
is the second, %2 is the third, etc.).
Create Actions
- Add entries to the actionsInfos array at the top of the
Main.cpp file. Each entry should use the following format:
Menu ID, String ID, Action Code, 0, Number of
Parameters, Parameter Types, Parameter String IDs,
List of Action
Parameter Types
- Create routines for each of your actions in Main.cpp. The
function header for action routines is short WINAPI
DLLExport Name(LPRDATA rdPtr, long param1, long param2).
If your action has less than 3 parameters, you can use param1
and param2 as those parameters. If you have more
than 2 parameters, you must get all of your
parameters using CNC_GetIntParameter(rdPtr), CNC_GetFloatParameter(rdPtr),
or CNC_GetParameter(rdPtr), which will return each
parameter on subsequent calls. Action routines should
return 0. Getting Parameters
- Add pointers to the action routines you've created to the
ActionJumps array at the bottom of Main.cpp. The order of
action routines in this array must be the same as the
order of actions in the actionsInfos array.
- Define your action codes in the Main.h file. The order of
these codes, which must be defined sequentially (0,1,2,3,etc.),
must be the same as the order of the actions in the
actionsInfos array. ACT_LAST must be the last action code
defined.
- Define the Menu IDs, String IDs, and Parameter String IDs
(the ones you used in the actionsInfos array) in the
Resource.h file.
- Add your actions to the MN_ACTIONS menu in the Extobj.rc
file, using the Menu IDs you used in the actionsInfos
array.
- Define the action and action parameter strings you used
in the actionsInfos array. The action parameter strings
are displayed in the heading of the expression evaluator
when the user is inputting the value for that parameter.
The action string is displayed in MMF's event and event
list editors. In that string, you can use %o to display
your object's icon and %# to display the given parameter
(%0 is the first parameter, %1 is the second, %2 is the
third, etc.).
Create Expressions
- Add entries to the expressionsInfos array at the top of
the Main.cpp file. Each entry should use the following
format:
Menu ID, String ID, Action Code, Return Type Flag,
Number of Parameters, Parameter Types, Parameter String
IDs,
Note: Parameter String IDs for expressions should be
0s.
List of Expression
Return and Parameter Types
- Create routines for each of your expressions in Main.cpp.
The function header for expression routines is long
WINAPI DLLExport Expression(LPRDATA rdPtr,long param1).
You get the first parameter by calling CNC_GetFirstExpressionParameter(rdPtr,
param1, Type). You get all other parameters by
subsequent calls of CNC_GetNextExpressionParameter(rdPtr,
param1, Type). Getting
Parameters
- Add pointers to the expression routines you've created to
the ExpressionJumps array at the bottom of Main.cpp. The
order of expression routines in this array must be the
same as the order of expressions in the expressionsInfos
array.
- Define your expression codes in the Main.h file. The
order of these codes, which must be defined sequentially
(0,1,2,3,etc.), must be the same as the order of the
expressions in the expressionsInfos array. EXP_LAST must
be the last action code defined.
- Define the Menu IDs and String IDs (the ones you used in
the expressionsInfos array) in the Resource.h file.
- Add your expressions to the MN_EXPRESSIONS menu in the
Extobj.rc file, using the Menu IDs you used in the
expressionsInfos array.
- Define the expression strings you used in the
expressionsInfos array. The expression string is how MMF
will show the expression in the expression evaluator.
Back to Matt's MMF Objects