Enterprise development using visual basic 6 0 autumn 2002 tirgul 7
This presentation is the property of its rightful owner.
Sponsored Links
1 / 27

Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul # 7 PowerPoint PPT Presentation


  • 65 Views
  • Uploaded on
  • Presentation posted in: General

Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul # 7. O bjectives. Brief on COM COM and Classes Creating Objects – ActiveX Dll Registering an Object Version Compatibility issues. Abstract.

Download Presentation

Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul # 7

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Enterprise development using visual basic 6 0 autumn 2002 tirgul 7

Enterprise Development Using Visual Basic 6.0 Autumn 2002Tirgul #7

‘Tirgul’ # 7


O bjectives

Objectives

  • Brief on COM

  • COM and Classes

  • Creating Objects – ActiveX Dll

  • Registering an Object

  • Version Compatibility issues

‘Tirgul’ # 7


Abstract

Abstract

  • In the world of the enterprise, employers want that something more then just Forms and Controls

  • That something is called COM

    • It's a way of organizing your code so it can be used over and over again.

    • It's a method of helping create a bug-free development environment.

    • Just after making your life a little harder, makes it lot easier.

‘Tirgul’ # 7


What is com

What is COM?

  • you're already a COM programmer!

    • Every time you set the Text property of a Text Box, you're using COM.

  • COM is a method of communication

‘Tirgul’ # 7


Com is a method of communication

COM is a method of communication

  • Imagine a television remote control

    • You press button one and the television tunes into Channel 1, 2…

    • You press the power button and the television turns itself off.

  • You just press the button and it jumps into action.

‘Tirgul’ # 7


Com is a method of communication1

COM is a method of communication

  • That’s applies to the world of programming.

  • You don't really know what happens when you change the Text property of your Text Box.

  • Under the covers, it's probably making two-dozen API calls – but to the end user, it just displays a certain piece of text in the box.

‘Tirgul’ # 7


Com is a way of reusing code

COM is a way of reusing code

  • You can use Com Object again and again anywhere.

    • A COM widget could be accessed from any program at any time. (Visual Basic, Excel C++ Program)

  • So COM is all about creating 'widgets' that can be reused.

‘Tirgul’ # 7


Com is based around real life objects

COM is based around real-life objects

  • After COM have been made, it’s easy to use.

  • Add a customer

    • Instead of adding lots of data access code, validation algorithms, and weighty database DLLs to your application – wouldn't it be easier to run something like

      Customer.Add

‘Tirgul’ # 7


Classes com

Classes -> COM

  • All of our work will be surrounding the creation of a class – which could later be turned into a real life COM object

‘Tirgul’ # 7


Classes check list

Classes check list

  • Variables

  • Properties (Let/Get) (hopefully)..

  • Subs, Functions, Parameters

  • Collection

  • What else?

    • Enumeration

    • Events – Not in the scope

‘Tirgul’ # 7


Create a real life com object

create a real-life COM object

  • ActiveX DLL– A .DLL program that contains classes.

  • ActiveX EXE – A .EXE program that contains classes.

  • ActiveX Control – A project that allows you to create controls in your toolbox.

  • ActiveX Document EXE – A program that runs on a Web page, in .EXE format.

  • ActiveX Document DLL – As above, but .DLL format.

‘Tirgul’ # 7


My first object

My first object!

  • We have discussed objects as controls in VB (Textbox, ComboBox) - you should be remembering these by now!)

  • When you make a control, it has a user interface (that means you can visually see something on the screen, such as the textbox itself

  • Another kind of object is one that doesn't have a user interface, and we call this a DLL (or Dynamic Link Library if you want to impress your friends).

‘Tirgul’ # 7


Activex dll

ActiveX Dll

  • Click File, New Project and select ActiveX DLL:

  • make sure that the Instancing property is set to 5 –MultiUse,

  • Allows us to compile the DLL and expose the class module to other programs (such as the object browser.

‘Tirgul’ # 7


Build the dll

Build the DLL

  • Save the project, and a click File, Make Project1.DLL.

  • You've just complied your first Dll object!

‘Tirgul’ # 7


Testing

Testing..

  • Add another project - File, Add Project, Standard EXE.

  • Because a DLL is not a control, we need to make a reference to it (because we are not loading any kind of user interface)

‘Tirgul’ # 7


Testing1

Testing..

  • Click File, References and scroll down and select Project1:

‘Tirgul’ # 7


Browsing the object

Browsing the Object

  • press F2 to load up the object browser and select Projec1 from the combo box.

  • Check the Methods..

‘Tirgul’ # 7


Explanation

Explanation

  • An ActiveX DLL's code is executed within the main program's address space.

  • It behaves as if the class was created within the main program's code.

  • Because the code lies inside the program's address space, calling methods is very fast.

‘Tirgul’ # 7


Registering a component

Registering a component

  • when you come to distribute your DLL to another machine and it doesn't work..

  • Each DLL (or component) on your machine has to be registered (including controls). Once registered, an entry in to the registry is made.

‘Tirgul’ # 7


Using regsvr32 tool

Using Regsvr32 Tool

  • Microsoft tool for registring DLL’s and OCX’s

  • Simply Drag the Object into the TextBox

‘Tirgul’ # 7


Main sub

Main sub

  • In the module you can add a main sub:

    Sub main

    ‘Add code that will run when the ‘component is created

    EndSub

‘Tirgul’ # 7


Compatibility

Compatibility

  • Problem:

    • compile the ActiveX DLL,

    • then compiled a test program that used our DLL.

    • Then we recompiled our DLL – something you usually do after you make changes.

  • Suddenly, our test program no longer worked!

‘Tirgul’ # 7


Compatibility1

Compatibility

  • Open up your project

  • Click 'Project Properties'

  • Click the 'Component' tab

‘Tirgul’ # 7


Version compatibility

Version Compatibility

  • No Compatibility – When compiled, your COM component gets assigned a new 'signature'. Programs looking for older 'signatures' (the previous version of the DLL) – simply flop

  • Project Compatibility – When compiled, your COM component is assigned a new signature – and still, any using-applications still flop. The only change here is that 'big' differences between your current project and a previous DLL project are highlighted as you compile.

  • Binary Compatibility – When compiled, your application attempts to keep the signature of a previously compiled DLL, thus ensuring any applications using it don't magically turn into the Blue Screen of Death. However if the differences between your previously compiled DLL and your to-be-compiled DLL are too great, a new signature must be assigned

‘Tirgul’ # 7


Activex dll creation summary

ActiveX DLL Creation Summary

When you create a new ActiveX DLL,

the steps you’ll generally follow are these:

  • Determine the features your component will provide.

  • Determine what objects are required to divide the functionality of the component in a logical fashion

‘Tirgul’ # 7


Activex dll creation summary1

ActiveX DLL Creation Summary

  • Design any forms your component will display.

  • Design the interface — that is, the properties, methods, and events — for each class provided by your component.

  • Create a project group consisting of your component project and a test project.

‘Tirgul’ # 7


Activex dll creation summary2

ActiveX DLL Creation Summary

  • Implement the forms required by your component

  • Implement the interface of each class.

  • As you add each interface element or feature, add features to your test project to exercise the new functionality.

  • Compile your DLL and test it with all potential target applications.

‘Tirgul’ # 7


  • Login