Make an ActiveX DLL

I l @ ve RuBoard

SET THE DEFAULT LANGUAGE TO VISUAL BASIC AND THE STEREOTYPE DISPLAY TO LABEL

graphics/quatranirose_icon.gif
  1. Select the Tools:Options menu command.

  2. Select the Notation tab.

  3. Click the arrow in the Default Language field to make the drop-down menu visible.

  4. Select Visual Basic.

  5. Select the Diagram tab.

  6. Select the Label radio button in the Stereotype Display field.

  7. Click the OK button to close the Options window.

SET VISUAL BASIC CODE GENERATION OPTIONS

graphics/quatranirose_icon.gif
  1. Select the Tools:Visual Basic:Properties menu command.

  2. Deselect the Generate debug code and the Generate error-handling code checkboxes.

  3. Click the OK button to close the Visual Basic Properties window.

CREATE THE PAYCLERK CLASS

graphics/quatranirose_icon.gif
  1. Click the + next to the Logical View package in the Browser to expand the view.

  2. Double-click on the diagram called Main to open the diagram.

  3. Select the Class icon on the toolbar.

  4. Click on the Main class diagram to create the class.

  5. While the class is still selected, enter its name . . . Payclerk.

GIVE THE PAYCLERK DOCUMENTATION AND AN OPERATION

graphics/quatranirose_icon.gif
  1. Double-click on the class on either the Main class diagram or in the Browser to open the Class Specification.

  2. Enter the documentation for the Payclerk in the Documentation field . . . a Payclerk calculates weekly pay.

  3. Select the Operations tab.

  4. Right-click to make the shortcut menu visible.

  5. Select the Insert menu choice. This will insert an operation called opname.

  6. While the operation is still selected, enter its name . . . calcPay.

  7. Click the OK button to close the Class Specification.

SET THE ARGUMENTS AND RETURN TYPE FOR THE CALCPAY OPERATION

graphics/quatranirose_icon.gif
  1. Click the + next to the Logical View package in the Browser to expand the package.

  2. Click the + next to the Payclerk class in the Browser to expand the class.

  3. Double-click on the calcPay operation to make the Operation Specification visible.

  4. Click the arrow in the Return class field to make the drop-down menu visible.

  5. Select Currency.

  6. Select the Detail tab.

  7. Right-click in the Arguments field to make the shortcut menu visible.

  8. Select the Insert menu choice. This will insert an argument called argname.

  9. While the new argument is still selected, enter its name . . . rate.

  10. Click the Type field to make the drop-down menu visible.

  11. Select Integer.

  12. Click the OK button to close the Operation Specification.

CREATE THE IPAYROLL INTERFACE CLASS

graphics/quatranirose_icon.gif
  1. Right-click on the Logical View package in the Browser to make the shortcut menu visible.

  2. Select the New: Interface menu choice. This will insert a new class with a Stereotype of Interface in the Browser.

  3. While the new interface class is still selected, enter its name . . . IPayroll.

ADD THE INTERFACE CLASS TO THE MAIN CLASS DIAGRAM

graphics/quatranirose_icon.gif
  1. Open the Main class diagram by double-clicking on the diagram called Main in the Logical View package of the Browser.

  2. Click to select the IPayroll class in the Browser.

  3. Drag the class onto the Main class diagram.

ADD AN OPERATION TO THE IPAYROLL CLASS

graphics/quatranirose_icon.gif
  1. Right-click on the IPayroll class on the Main class diagram to make the shortcut menu visible.

  2. Select the New:Operation menu choice. This will add a new operation called opname to the class.

  3. While the new operation is still selected, enter its name and return type . . . calcPay(rate:Integer):Currency (make sure you use this format).

CREATE THE PAYROLL CLASS

graphics/quatranirose_icon.gif
  1. Right-click on the Logical View package in the Browser to make the shortcut menu visible.

  2. Select the New: Class menu choice. This will insert a new class in the Browser.

  3. While the new class is still selected, enter its name . . . Payroll.

ADD THE PAYROLL CLASS TO THE MAIN CLASS DIAGRAM

graphics/quatranirose_icon.gif
  1. Open the Main class diagram by double-clicking on the diagram called Main in the Logical View package of the Browser.

  2. Click to select the Payroll class in the Browser.

  3. Drag the class onto the Main class diagram.

CREATE A REALIZE RELATIONSHIP BETWEEN THE IPAYROLL CLASS AND THE PAYROLL CLASS

graphics/quatranirose_icon.gif
  1. Click to select the Realize icon on the toolbar.

  2. Click on the Payroll class on the Main class diagram and drag the association to the IPayroll class.

CREATE A RELATIONSHIP BETWEEN THE PAYROLL CLASS AND THE PAYCLERK CLASS

graphics/quatranirose_icon.gif
  1. Click to select the Unidirectional Association icon on the toolbar.

  2. Click on the Payroll class on the Main class diagram and drag the association to the Payclerk class.

CREATE A ROLL NAME

graphics/quatranirose_icon.gif
  1. Right-click on the association near the Payclerk class to make the shortcut menu visible.

  2. Select the Role name menu choice. This will add a role name called thePayClerk to the diagram.

  3. While the role name is still selected, enter its name . . . myClerk.

MAKE THE ASSOCIATION PRIVATE

graphics/quatranirose_icon.gif
  1. Right-click on the association near the Payclerk class to make the shortcut menu visible.

  2. Select the Private menu choice.

SET THE MULTIPLICITY

graphics/quatranirose_icon.gif
  1. Right-click on the association near the Payclerk class to make the shortcut menu visible.

  2. Select the Multiplicity:1 menu choice.

USE THE MODEL ASSISTANT TO SET CODE GENERATION PROPERTIES FOR THE IPAYROLL INTERFACE

graphics/quatranirose_icon.gif
  1. Right-click on the IPayroll class on the class diagram or in the Browser to make the shortcut menu visible.

  2. Select the Model Assistant menu choice.

  3. Select IPayroll in the Model Assistant tree view.

  4. Click the arrow in the Instancing field to make the drop-down menu visible.

  5. Select MultiUse.

  6. Click the OK button to close the Model Assistant.

USE THE MODEL ASSISTANT TO SET CODE GENERATION PROPERTIES FOR THE PAYROLL CLASS

graphics/quatranirose_icon.gif
  1. Right-click on the Payroll class on the class diagram or in the Browser to make the shortcut menu visible.

  2. Select the Model Assistant menu choice.

  3. Select Payroll in the Model Assistant tree view.

  4. Click the arrow in the Instancing field to make the drop-down menu visible.

  5. Select MultiUse.

  6. Click the + next to the Implements Classes package in the tree view to expand the view.

  7. Click the + next to IPayroll in the tree view to expand the view.

  8. Select the IPayroll_calcPay operation.

  9. Select the Public radio button in the Access field.

  10. Click the + next to the Properties package in the tree view to expand the view.

  11. Click the + next to myClerk in the tree view to expand the view.

  12. Select myClerk.

  13. Click the New checkbox.

  14. Click the OK button to close the Model Assistant.

CREATE THE PAYROLLCALCULATOR COMPONENT

graphics/quatranirose_icon.gif
  1. Right-click on the Component View package in the Browser to make the shortcut menu visible.

  2. Select the New: Component menu choice. This will add a component called NewComponent to the Browser.

  3. While the new component is still selected, enter its name . . . PayrollCalculator.

ASSIGN A STEREOTYPE TO THE PAYROLL

graphics/quatranirose_icon.gif
  1. Right-click on the PayrollCalculator component in the Browser to make the shortcut menu visible.

  2. Select the Open Specification menu choice.

  3. Click the arrow in the Stereotype field to make the drop-down menu visible.

  4. Select ActiveX DLL.

  5. Click the OK button to close the Component Specification.

ADD THE COMPONENT TO THE MAIN COMPONENT DIAGRAM

graphics/quatranirose_icon.gif
  1. Double-click on the diagram called Main in the Component View package of the Browser to open the diagram.

  2. Click to select the PayrollCalculator component in the Browser and drag it onto the diagram.

ASSIGN THE CLASSES TO THE PAYROLLCALCULATOR COMPONENT

  1. Double-click on the Payroll component on the diagram or in the Browser to make the Component Specification visible.

  2. Select the Realizes tab.

  3. Click to select the IPayroll class.

  4. Press the Shift button.

  5. Click to select the Payroll class.

  6. Click to select the Payclerk class.

  7. Right-click to make the pop-up menu visible.

  8. Select the Assign menu choice.

  9. Click the OK button to close the Component specification.

GENERATE THE VISUAL BASIC CODE

graphics/quatranirose_icon.gif
  1. Click to select the PayrollCalculator component on the Component Diagram.

  2. Select the Tools:Visual Basic:Update code menu choice to make the Code Update tool visible.

  3. Select the Finish button on the Code Update tool.

  4. You will be prompted to save the model. Enter PayrollCalculator in the Filename field and click the Save button.

  5. When the code generation is complete, the Summary window is displayed. Click the Close button to close the Code Update tool.

ADD THE METHOD CODE FOR THE PAYCLERK CLASS

graphics/quatranirose_icon.gif
  1. In Visual Basic, go to the calcPay method of the Payclerk class.

  2. Add the following code: calcPay = rate * 40

  3. In Visual Basic, go to the IPayroll_calcPay method of the Payroll class.

  4. Add the following code: IPayroll_calcPay = myClerk.calcPay(rate)

  5. Select the Project:PayrollCalculator Properties menu choice.

  6. Click the arrow in the Startup Object field to make the drop-down menu visible.

  7. Select (None).

  8. Click the OK button to close the Project Properties window.

  9. Select the File:Make PayrollCalculator.dll . . . menu choice.

  10. Click the OK button in the Make Project window to save the new dll.

  11. Select the File:Exit menu choice to exit Visual Basic (you do not have to save the files).

I l @ ve RuBoard


Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net